Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Performance

New issue 1337 by [email protected]: constant regexps are always re-constructed every time they're used
http://code.google.com/p/google-caja/issues/detail?id=1337

when js uses a constant regexp like

    s = s.replace(/\s+/, '');

the es53 rewriter turns it into something like this:

    s = (x0___ = new RegExp.new___('\\s+'), s.replace_m___?
        s.replace(x0___, 'x'): s.m___('replace', [ x0___, 'x' ]

which means a new RegExp object is constructed every time that code is executed.

RegExp construction is kind of expensive, not just the parse time of the RegExp. each RegExp construction calls DefineOwnProperty___ five times, and DefineOwnProperty___ is kind of expensive.

(this is one of of the reasons the markdown example is sluggish when cajoled.)

Reply via email to