|
|
|
|
|
by Klathmon
3675 days ago
|
|
Somewhat off topic, but is there a "regex alternation optimizer" out there? And would something like that be worth it? I've looked through some textmate-style syntax highlighting packages (used in sublime and in github's atom and probably others), and most of them need big (or somewhat big) sets of alternations for a bunch of keywords, and more often than not they are just set up as a list of full keywords with no thought to order or size. Combining them into something like the below should theoretically be faster while also taking up less space (which is important in web libraries), and I feel like it wouldn't even be all that difficult. de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)
Is there something out there which can do this, and would it even be worth it or is this something best left to the JIT/optimizer of the regex engine? |
|
https://en.wikipedia.org/wiki/Trie#Algorithms
I'm not so sure it would take up much less space though, if you take gzip compression into account. See for example here:
https://github.com/google/closure-compiler/wiki/FAQ#closure-...