Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Some RegExp optimizations #70

Open
devinrhode2 opened this issue Nov 19, 2012 · 1 comment
Open

Some RegExp optimizations #70

devinrhode2 opened this issue Nov 19, 2012 · 1 comment

Comments

@devinrhode2
Copy link

I give full credit to closure compiler for this.
I cleaned up the output a lot, the WARNING's are all for the same References to the global RegExp object prevents optimization of regular expressions.

twitter-text.js:787: WARNING - References to the global RegExp object prevents optimization of regular expressions.
        RegExp.rightContext.match(twttr.txt.regexen.endMentionMatch)) {
        ^

twitter-text.js:817: WARNING 
      var before = RegExp.$2, url = RegExp.$3, protocol = RegExp.$4, domain = RegExp.$5, path = RegExp.$7;
                   ^                ^                     ^                   ^                 ^

twitter-text.js:860: WARNING 
          url = RegExp.lastMatch;
                ^

twitter-text.js:1268: WARNING
      return ((typeof string === "string") && string.match(regex) && RegExp["$&"] === string);
                                                                     ^

twitter-text.js:1272: WARNING
    return (!string || (string.match(regex) && RegExp["$&"] === string));
                                               ^
@lukeasrodgers
Copy link
Contributor

IIRC, the reason why closure compiler can't optimize these is precisely because you can do things like RegExp.$1, which this library does in a bunch of places, so fixing these warnings would require a significant refactor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants