mathiasbynens / jsesc

Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.
https://mths.be/jsesc
MIT License
716 stars 48 forks source link

Replace string escaping with regex replace #61

Closed jridgewell closed 4 years ago

jridgewell commented 4 years ago

This allows the engine to skip all blocks of valid ASCII chars, considerably speeding it up. The tests, which include an escape for every 16th code point between 0 and 0x10FFFF, goes from ~24s to ~700ms (a 34x speedup).

This subsumes https://github.com/mathiasbynens/jsesc/pull/60.

mathiasbynens commented 4 years ago

Amazing! Thank you :)