Closed peteruhnak closed 4 years ago
Hi. Can you sign contributors.txt too?
Hi. Can you sign contributors.txt too?
done
I've realized that the previous \>>
case was a subset of the new one so I merged them.
This looks like it could have poor performance if s is very long.
I've also changed the substring to startsWith for all cases.
Out of curiosity I did some basic benchmarks on some files I had:
*Substring
is the original implementation*StartsWith
is the new implementation*Char
is experimental implementation that operates on char[] instead of String, but makes it less readable (so imo not worth it unless someone is parsing thousands of massive templates at once)test name | ops/s | size in chars | ops/s * size |
---|---|---|---|
EscapeChangePerf.benchTinySubstring | 2,059,220 | 34 | 70,013,489 |
EscapeChangePerf.benchTinyStartsWith | 3,154,894 | 34 | 107,266,400 |
EscapeChangePerf.benchTinyChar | 10,831,791 | 34 | 368,280,883 |
EscapeChangePerf.benchSmallSubstring | 75,085 | 966 | 72,532,051 |
EscapeChangePerf.benchSmallStartsWith | 128,906 | 966 | 124,522,734 |
EscapeChangePerf.benchSmallChar | 455,153 | 966 | 439,677,458 |
EscapeChangePerf.benchMediumSubstring | 7,465 | 5,403 | 40,330,775 |
EscapeChangePerf.benchMediumStartsWith | 24,014 | 5,403 | 129,749,603 |
EscapeChangePerf.benchMediumChar | 96,988 | 5,403 | 524,023,722 |
EscapeChangePerf.benchLargeSubstring | 628 | 22,556 | 14,165,145 |
EscapeChangePerf.benchLargeStartsWith | 5,713 | 22,556 | 128,858,481 |
EscapeChangePerf.benchLargeChar | 21,201 | 22,556 | 478,209,418 |
Ok, looks great. Thanks guys.
This reintroduces closing angle bracket escaping as discussed in https://github.com/antlr/stringtemplate4/issues/198 .
Note that this applies only to
STGroup
, notST
-- same way it was in 4.0.4 and prior.