Skip to content
Browse files

Optimize the string action method somewhat; gives a ~30% win for proj…

…ects.json.
  • Loading branch information...
1 parent 138468c commit 099d4d748a5b2cf10ae3018d66285ad6c76cee34 @jnthn jnthn committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/JSON/Tiny/Actions.pm
View
4 lib/JSON/Tiny/Actions.pm
@@ -20,7 +20,9 @@ method array($/) {
}
method string($/) {
- make join '', $0.list.map({ (.<str> || .<str_escape>).ast });
+ make $0.elems == 1
+ ?? ($0[0].<str> || $0[0].<str_escape>).ast
+ !! join '', $0.list.map({ (.<str> || .<str_escape>).ast });
}
method value:sym<number>($/) { make +$/.Str }
method value:sym<string>($/) { make $<string>.ast }

0 comments on commit 099d4d7

Please sign in to comment.
Something went wrong with that request. Please try again.