mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +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
dist/lodash.js
vendored
17
dist/lodash.js
vendored
@@ -29,7 +29,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,
|
||||
@@ -320,6 +320,7 @@
|
||||
function getObject() {
|
||||
return objectPool.pop() || {
|
||||
'array': null,
|
||||
'cache': null,
|
||||
'criteria': null,
|
||||
'false': false,
|
||||
'index': 0,
|
||||
@@ -353,11 +354,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,11 +371,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