Closed pie6k closed 4 years ago
This function is called very often, so creating variables inside will lead to more garbage collections required
Also, probably regexps that are shared between comparisons might get optimized by JS engine, while inline regexp creates new 'instance' each time.
https://jsperf.com/regexp-vs-compiled-regexp/1
Thanks! Could you publish it to npm? :)
v2.1.3 released!
This function is called very often, so creating variables inside will lead to more garbage collections required
Also, probably regexps that are shared between comparisons might get optimized by JS engine, while inline regexp creates new 'instance' each time.