eslint/eslint — pull request #1216 by btmills (2014-09-04 07:49:21+00:00)
Title: Fix: Speed up getScope() (refs #1212)

Instead of `reverse`ing, iterates the `parents` list backwards. Indexes scopes for direct random lookup rather than searching through them linearly.

`npm run perf` before and after:

```
CPU Speed is 2200 with multiplier 7500000
Performance Run #1: 1883.021533ms
Performance Run #2: 1865.9190469999999ms
Performance Run #3: 1856.122294ms
Performance Run #4: 1871.876902ms
Performance Run #5: 1854.4841139999999ms
Performance budget ok: 1865.9190469999999ms (limit: 3409.090909090909ms)
```

```
CPU Speed is 2200 with multiplier 7500000
Performance Run #1: 1579.674679ms
Performance Run #2: 1637.630723ms
Performance Run #3: 1578.9458220000001ms
Performance Run #4: 1569.7571480000001ms
Performance Run #5: 1575.484874ms
Performance budget ok: 1578.9458220000001ms (limit: 3409.090909090909ms)
```

In `npm run profile`, `getScope` dropped from 6.23% of total time down to 0.38%.

In a separate local branch, I added some code to track processing time consumed by each rule. `no-unused-vars` is still the slowest rule by a large margin, but this change reduces it from 35% of total rule time down to 22% (those numbers on `tests/performance/jshint.js`).