mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
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:
17
lodash.js
17
lodash.js
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user