diff options
| author | Sekib Omazic | 2014-02-12 11:33:50 +0100 |
|---|---|---|
| committer | Igor Minar | 2014-02-21 22:29:46 -0800 |
| commit | a4078fcae4a33295675d769a1cd067837029da2f (patch) | |
| tree | 5d8a8550d6e67188c1945a85d9c4a7aa579b8770 /src/ng | |
| parent | 39c82f3fb7a8459304d5e07dc87bd0623ad1efd0 (diff) | |
| download | angular.js-a4078fcae4a33295675d769a1cd067837029da2f.tar.bz2 | |
perf($cacheFactory): skip LRU bookkeeping for caches with unbound capacity
Fixes #6193
Closes #6226
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/cacheFactory.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js index ea0195f6..c16c1e1f 100644 --- a/src/ng/cacheFactory.js +++ b/src/ng/cacheFactory.js @@ -59,9 +59,11 @@ function $CacheFactoryProvider() { return caches[cacheId] = { put: function(key, value) { - var lruEntry = lruHash[key] || (lruHash[key] = {key: key}); + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key] || (lruHash[key] = {key: key}); - refresh(lruEntry); + refresh(lruEntry); + } if (isUndefined(value)) return; if (!(key in data)) size++; @@ -76,26 +78,31 @@ function $CacheFactoryProvider() { get: function(key) { - var lruEntry = lruHash[key]; + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; - if (!lruEntry) return; + if (!lruEntry) return; - refresh(lruEntry); + refresh(lruEntry); + } return data[key]; }, remove: function(key) { - var lruEntry = lruHash[key]; + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; - if (!lruEntry) return; + if (!lruEntry) return; - if (lruEntry == freshEnd) freshEnd = lruEntry.p; - if (lruEntry == staleEnd) staleEnd = lruEntry.n; - link(lruEntry.n,lruEntry.p); + if (lruEntry == freshEnd) freshEnd = lruEntry.p; + if (lruEntry == staleEnd) staleEnd = lruEntry.n; + link(lruEntry.n,lruEntry.p); + + delete lruHash[key]; + } - delete lruHash[key]; delete data[key]; size--; }, |
