wincent / masochist

⛓ Website infrastructure for over-engineers
MIT License
78 stars 26 forks source link

Consider flattening and simplifying inverted character classes #183

Closed wincent closed 2 years ago

wincent commented 2 years ago

eg. instead of nesting:

/[\D1-5]/

could expand out to:

/[\x00-x2f\x3a-\uffff1-5]/

and further simplified to:

/[\x00-\x35\x3a-\uffff]/

by sorting and then merging overlapping ranges.

wincent commented 2 years ago

Mostly done in https://github.com/wincent/masochist/commit/c4bb673ca30af31f43a7dcf4c0129b26659316a5, I think.