Increase maxPoolSize limit, add missing cache property to the object returned by getObject, and optimize releaseArray and releaseObject.

Former-commit-id: 41c356fb0d03339bc450de8d69f8002aa4613628
This commit is contained in:
John-David Dalton
2013-06-12 00:28:18 -07:00
parent 7de892ccac
commit fcffcdde1b
6 changed files with 185 additions and 188 deletions

View File

@@ -28,7 +28,7 @@
var largeArraySize = 75;
/** Used as the max size of the `arrayPool` and `objectPool` */
var maxPoolSize = 10;
var maxPoolSize = 40;
/** Used to match empty string literals in compiled template source */
var reEmptyStringLeading = /\b__p \+= '';/g,
@@ -327,6 +327,7 @@
'args': '',
'array': null,
'bottom': '',
'cache': null,
'criteria': null,
'false': false,
'firstArg': '',
@@ -381,11 +382,10 @@
* @param {Array} [array] The array to release.
*/
function releaseArray(array) {
if (arrayPool.length == maxPoolSize) {
arrayPool.length = maxPoolSize - 1;
}
array.length = 0;
arrayPool.push(array);
if (arrayPool.length < maxPoolSize) {
arrayPool.push(array);
}
}
/**
@@ -399,11 +399,10 @@
if (cache) {
releaseObject(cache);
}
if (objectPool.length == maxPoolSize) {
objectPool.length = maxPoolSize - 1;
}
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
objectPool.push(object);
if (objectPool.length < maxPoolSize) {
objectPool.push(object);
}
}
/**