Skip to content

Commit 5335c53

Browse files
committed
lib: mark items returned from freelist directly in alloc
1 parent 3d41d4f commit 5335c53

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/internal/freelist.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ class FreeList {
1111
}
1212

1313
alloc() {
14-
return this.list.length ?
15-
setIsReused(this.list.pop(), true) :
16-
setIsReused(this.ctor.apply(this, arguments), false);
14+
let item;
15+
if (this.list.length > 0) {
16+
item = this.list.pop();
17+
item[is_reused_symbol] = true;
18+
} else {
19+
item = this.ctor.apply(this, arguments);
20+
item[is_reused_symbol] = false;
21+
}
22+
return item;
1723
}
1824

1925
free(obj) {
@@ -25,11 +31,6 @@ class FreeList {
2531
}
2632
}
2733

28-
function setIsReused(item, reused) {
29-
item[is_reused_symbol] = reused;
30-
return item;
31-
}
32-
3334
module.exports = {
3435
FreeList,
3536
symbols: {

0 commit comments

Comments
 (0)