beardedspice/beardedspice — pull request #85 by 1ps0 (2014-11-03 00:34:17+00:00)
Title: Improved load time

Added a cache in MediaStrategyRegistry that will cache the results of previous queries. This effectively reduces the scan time from 0.02s per tab to 0.005s on any menu load after the first.

The use of beginStrategyQueries/endStrategyQueries is to allow the cleanup of the cache, removing any entries for tabs that no longer exist.
However, running getMediaStrategyForTab: without the wrapper methods will not cause any issues, only a potential memory bloat over a very long period of time (depending on frequency of menu opens vs number of tab changes).

Also applied some best practices to the overall code structure of MediaStrategyRegistry to ensure it being threadsafe against any future changes.