aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/cacheFactory.js
diff options
context:
space:
mode:
authorSekib Omazic2014-02-12 11:33:50 +0100
committerIgor Minar2014-02-21 22:29:46 -0800
commita4078fcae4a33295675d769a1cd067837029da2f (patch)
tree5d8a8550d6e67188c1945a85d9c4a7aa579b8770 /src/ng/cacheFactory.js
parent39c82f3fb7a8459304d5e07dc87bd0623ad1efd0 (diff)
downloadangular.js-a4078fcae4a33295675d769a1cd067837029da2f.tar.bz2
perf($cacheFactory): skip LRU bookkeeping for caches with unbound capacity
Fixes #6193 Closes #6226
Diffstat (limited to 'src/ng/cacheFactory.js')
-rw-r--r--src/ng/cacheFactory.js29
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--;
},