10000 Increase `maxPoolSize` limit, add missing `cache` property to the obj… · lodash/lodash@fcffcdd · GitHub
[go: up one dir, main page]

Skip to content

Commit fcffcdd

Browse files
committed
Increase maxPoolSize limit, add missing cache property to the object returned by getObject, and optimize releaseArray and releaseObject.
Former-commit-id: 41c356fb0d03339bc450de8d69f8002aa4613628
1 parent 7de892c commit fcffcdd

File tree

6 files changed

+185
-188
lines changed

6 files changed

+185
-188
lines changed

dist/lodash.compat.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
var largeArraySize = 75;
3030

3131
/** Used as the max size of the `arrayPool` and `objectPool` */
32-
var maxPoolSize = 10;
32+
var maxPoolSize = 40;
3333

3434
/** Used to match empty string literals in compiled template source */
3535
var reEmptyStringLeading = /\b__p \+= '';/g,
@@ -328,6 +328,7 @@
328328
'args': '',
329329
'array': null,
330330
'bottom': '',
331+
'cache': null,
331332
'criteria': null,
332333
'false': false,
333334
'firstArg': '',
@@ -381,11 +382,10 @@
381382
* @param {Array} [array] The array to release.
382383
*/
383384
function releaseArray(array) {
384-
if (arrayPool.length == maxPoolSize) {
385-
arrayPool.length = maxPoolSize - 1;
386-
}
387385
array.length = 0;
388-
arrayPool.push(array);
386+
if (arrayPool.length < maxPoolSize) {
387+
arrayPool.push(array);
388+
}
389389
}
390390

391391
/**
@@ -399,11 +399,10 @@
399399
if (cache) {
400400
releaseObject(cache);
401401
}
402-
if (objectPool.length == maxPoolSize) {
403-
objectPool.length = maxPoolSize - 1;
404-
}
405402
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
406-
objectPool.push(object);
403+
if (objectPool.length < maxPoolSize) {
404+
objectPool.push(object);
405+
}
407406
}
408407

409408
/**

dist/lodash.compat.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lodash.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
var largeArraySize = 75;
3030

3131
/** Used as the max size of the `arrayPool` and `objectPool` */
32-
var maxPoolSize = 10;
32+
var maxPoolSize = 40;
3333

3434
/** Used to match empty string literals in compiled template source */
3535
var reEmptyStringLeading = /\b__p \+= '';/g,
@@ -320,6 +320,7 @@
320320
function getObject() {
321321
return objectPool.pop() || {
322322
'array': null,
323+
'cache': null,
323324
'criteria': null,
324325
'false': false,
325326
'index': 0,
@@ -353,11 +354,10 @@
353354
* @param {Array} [array] The array to release.
354355
*/
355356
function releaseArray(array) {
356-
if (arrayPool.length == maxPoolSize) {
357-
arrayPool.length = maxPoolSize - 1;
358-
}
359357
array.length = 0;
360-
arrayPool.push(array);
358+
if (arrayPool.length < maxPoolSize) {
359+
arrayPool.push(array);
360+
}
361361
}
362362

363363
/**
@@ -371,11 +371,10 @@
371371
if (cache) {
372372
releaseObject(cache);
373373
}
374-
if (objectPool.length == maxPoolSize) {
375-
objectPool.length = maxPoolSize - 1;
376-
}
377374
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
378-
objectPool.push(object);
375+
if (objectPool.length < maxPoolSize) {
376+
objectPool.push(object);
377+
}
379378
}
380379

381380
/**

0 commit comments

Comments
 (0)
0