diff options
| author | Phil Crosby | 2012-04-29 23:35:15 -0700 | 
|---|---|---|
| committer | Phil Crosby | 2012-04-30 00:13:07 -0700 | 
| commit | ff3d71cb6fa243d1e3b3a8d1c6b659f0e563fb39 (patch) | |
| tree | a774673211cb781aff564cd964d2bd0e74a88c51 /lib/completion.js | |
| parent | 152a4a6ce19b515a17455e3d545d20aaea14d0c5 (diff) | |
| download | vimium-ff3d71cb6fa243d1e3b3a8d1c6b659f0e563fb39.tar.bz2 | |
Rename matcher to regexp; matcher is overloaded and confusing.
Diffstat (limited to 'lib/completion.js')
| -rw-r--r-- | lib/completion.js | 22 | 
1 files changed, 11 insertions, 11 deletions
| diff --git a/lib/completion.js b/lib/completion.js index 1a8779a1..e8365b9c 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -327,7 +327,7 @@ var completion = (function() {      self.regexNonWord = /[\W_]/ig;      // cache generated regular expressions -    self.matcherCache = {}; +    self.regexpCache = {};      // cache filtered results from recent queries      self.filterCache = {};      self.normalizationCache = {}; @@ -349,7 +349,7 @@ var completion = (function() {       * efficient. There it falls back to a more performant, but less accurate regex matching if the       * normalized query is longer than 10 characters.       * -     * _Don't use this to check if a string matches a query_. Use `getMatcher(query).test(str)` instead. +     * _Don't use this to check if a string matches a query_. Use `getRegexp(query).test(str)` instead.       */      self.getMatchGroups = function(query, str) {        query = self.normalize(query); @@ -358,7 +358,7 @@ var completion = (function() {        if (query.length > 15) {          // for long query strings, the method is much too inefficient, so fall          // back to the less accurate regex matching -        return self.getMatcher(query).exec(str).slice(1); +        return self.getRegexp(query).exec(str).slice(1);        }        for (var i = query.length; i >= 1; --i) { @@ -401,8 +401,8 @@ var completion = (function() {      /** Trims the size of the caches to the configured size using a FIFO algorithm. */      self.cleanCache = function() {        // remove old cached regexes -      Object.keys(self.matcherCache).slice(self.cacheSize).forEach(function(query) { -        delete self.matcherCache[query]; +      Object.keys(self.regexpCache).slice(self.cacheSize).forEach(function(query) { +        delete self.regexpCache[query];        });        // remove old cached normalization results        Object.keys(self.normalizationCache).slice(self.cacheSize).forEach(function(query) { @@ -413,9 +413,9 @@ var completion = (function() {      /** Returns a regex that matches a string using a fuzzy :query. Example: The :query "abc" would result       * in a regex like /^([^a])*(a)([^b])*(b)([^c])*(c)(.*)$/       */ -    self.getMatcher = function(query) { +    self.getRegexp = function(query) {        query = self.normalize(query); -      if (!(query in self.matcherCache)) { +      if (!(query in self.regexpCache)) {          // build up a regex for fuzzy matching. This is the fastest method I checked (faster than:          // string building, splice, concat, multi-level join)          var regex = ['^']; @@ -427,9 +427,9 @@ var completion = (function() {            regex.push(')');          }          regex.push('(.*)$'); -        self.matcherCache[query] = new RegExp(regex.join(''), 'i'); +        self.regexpCache[query] = new RegExp(regex.join(''), 'i');        } -      return self.matcherCache[query]; +      return self.regexpCache[query];      }      /** Clear the cache for the given source, e.g. for refreshing */ @@ -476,8 +476,8 @@ var completion = (function() {          self.cleanCache();        } -      var matcher = self.getMatcher(query); -      var filtered = source.filter(function(x) { return matcher.test(getValue(x)) }); +      var regexp = self.getRegexp(query); +      var filtered = source.filter(function(x) { return regexp.test(getValue(x)) });        self.filterCache[id][query] = filtered;        return filtered;      } | 
