I'm not surprised, v8 has a RegExp JIT (irregexp IIRC) which used to be 20x faster than SpiderMonkey's RegExp for simple patterns.
Back when I was playing with parsers in JS, the fastest approach to anything string-related was through RegExp, even trivial tasks like "first character is X".
The caveat, of course, was that you would only get that performance under v8.
Nowadays it should be more balanced, but I have no idea how v8 compares to SM anymore.
eddyb|10 years ago
Back when I was playing with parsers in JS, the fastest approach to anything string-related was through RegExp, even trivial tasks like "first character is X".
The caveat, of course, was that you would only get that performance under v8.
Nowadays it should be more balanced, but I have no idea how v8 compares to SM anymore.