Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Speed up string parsing around 100 times
The problem was that the Match.caps is using sort(), which is quite slow
which  becomes annoying when you have over 1000 json strings in your
json file.

Kudos to jnthn++ for figuring this out.
  • Loading branch information
Tadeusz Sośnierz committed Mar 6, 2011
1 parent 81d8026 commit bca5efa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/JSON/Tiny/Actions.pm
Expand Up @@ -23,7 +23,7 @@ method array($/) {
}

method string($/) {
make join '', $/.caps>>.value>>.ast
make join '', $0.list.map({ (.<str> || .<str_escape>).ast });
}
method value:sym<number>($/) { make eval $/.Str }
method value:sym<string>($/) { make $<string>.ast }
Expand Down
2 changes: 1 addition & 1 deletion lib/JSON/Tiny/Grammar.pm
Expand Up @@ -22,7 +22,7 @@ token value:sym<array> { <array> };
token value:sym<string> { <string> }

token string {
\" ~ \" [ <str> | \\ <str_escape> ]*
\" ~ \" ( <str> | \\ <str_escape> )*
}

token str {
Expand Down

0 comments on commit bca5efa

Please sign in to comment.