ilyavolodin / eslint-plugin-backbone

Backbone specific linting rules for ESLint
MIT License
95 stars 11 forks source link

Fix exponentially growing settings arrays. (fixes #29) #44

Closed texclayton closed 9 years ago

texclayton commented 9 years ago

normalizeSettings is invoked every time isBackboneView/Model/Collection is invoked (for every rule in the plugin, for every node). This causes exponential growth in the arrays of the settings object, which slows down the linear searches performed in isBackboneBase. A simple fix is to create a new Object every time normalizeSettings is invoked.

If the settings do not change over the lifetime of the process, then the normalized settings can be cached for further performance benefit. The same can be done for the prefixes array created in isBackboneBase. The unit tests do change the settings, so some checking needs to be implemented to detect cache hits/misses, or the unit tests need to be modified.

@rsk7 @gshenar helped me profile, analyze, and fix this issue.

ilyavolodin commented 9 years ago

Nice catch! Build is failing because code coverage went down after this change. I'm not really sure why, but I will take a look.