EFForg/https-everywhere — pull request #14 by semenko (2013-12-20 06:11:19+00:00)
Title: Chrome performance: cache potentiallyApplicableRulesets

(for issue #12)

The function "potentiallyApplicableRulesets" is hot, and its results are stable.

From profiling, this is *very* slow, and it's easy to see why. The calls look like:

Loading www.nytimes.com ->
Load every image (20+ images at graphics8.nytimes.com)
Call potentiallyApplicableRulesets every time
Return the same result every time :(

Let's use a simple LRU cache to store those results.

This adds the MIT-licensed LRU cache from: https://github.com/rsms/js-lru

The cache isn't persistent (it's in memory, not LocalStorage or elsewhere),
so we don't have to worry about stale data when the extension updates.

Signed-off-by: Nick Semenkovich