Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixhup: less primordials in hot path
  • Loading branch information
mcollina committed Apr 15, 2021
commit dbbdd596835b45eebfc07e58f2c11adca281d46e
4 changes: 0 additions & 4 deletions lib/internal/fixed_queue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
'use strict';

const {
Array,
} = primordials;

// Currently optimal queue size, tested on V8 6.0 - 6.6. Must be power of two.
const kSize = 2048;
const kMask = kSize - 1;
Expand Down
1 change: 0 additions & 1 deletion lib/internal/stream_base_commons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {
Array,
Symbol,
} = primordials;

Expand Down
20 changes: 9 additions & 11 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const {
ArrayFrom,
ArrayIsArray,
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSort,
Expand All @@ -22,7 +21,6 @@ const {
SafeMap,
SafeSet,
StringPrototypeReplace,
StringPrototypeToLowerCase,
StringPrototypeToUpperCase,
Symbol,
SymbolFor,
Expand Down Expand Up @@ -141,13 +139,13 @@ function slowCases(enc) {
case 4:
if (enc === 'UTF8') return 'utf8';
if (enc === 'ucs2' || enc === 'UCS2') return 'utf16le';
enc = StringPrototypeToLowerCase(`${enc}`);
enc = `${enc}`.toLowerCase();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those changes where needed because slowCases did not inline anymore.

if (enc === 'utf8') return 'utf8';
if (enc === 'ucs2') return 'utf16le';
break;
case 3:
if (enc === 'hex' || enc === 'HEX' ||
StringPrototypeToLowerCase(`${enc}`) === 'hex')
`${enc}`.toLowerCase() === 'hex')
return 'hex';
break;
case 5:
Expand All @@ -156,7 +154,7 @@ function slowCases(enc) {
if (enc === 'UTF-8') return 'utf8';
if (enc === 'ASCII') return 'ascii';
if (enc === 'UCS-2') return 'utf16le';
enc = StringPrototypeToLowerCase(`${enc}`);
enc = `${enc}`.toLowerCase();
if (enc === 'utf-8') return 'utf8';
if (enc === 'ascii') return 'ascii';
if (enc === 'ucs-2') return 'utf16le';
Expand All @@ -166,23 +164,23 @@ function slowCases(enc) {
if (enc === 'latin1' || enc === 'binary') return 'latin1';
if (enc === 'BASE64') return 'base64';
if (enc === 'LATIN1' || enc === 'BINARY') return 'latin1';
enc = StringPrototypeToLowerCase(`${enc}`);
enc = `${enc}`.toLowerCase();
if (enc === 'base64') return 'base64';
if (enc === 'latin1' || enc === 'binary') return 'latin1';
break;
case 7:
if (enc === 'utf16le' || enc === 'UTF16LE' ||
StringPrototypeToLowerCase(`${enc}`) === 'utf16le')
`${enc}`.toLowerCase() === 'utf16le')
return 'utf16le';
break;
case 8:
if (enc === 'utf-16le' || enc === 'UTF-16LE' ||
StringPrototypeToLowerCase(`${enc}`) === 'utf-16le')
`${enc}`.toLowerCase() === 'utf-16le')
return 'utf16le';
break;
case 9:
if (enc === 'base64url' || enc === 'BASE64URL' ||
StringPrototypeToLowerCase(`${enc}`) === 'base64url')
`${enc}`.toLowerCase() === 'base64url')
return 'base64url';
break;
default:
Expand All @@ -202,7 +200,7 @@ function filterDuplicateStrings(items, low) {
const map = new SafeMap();
for (let i = 0; i < items.length; i++) {
const item = items[i];
const key = StringPrototypeToLowerCase(item);
const key = item.toLowerCase();
if (low) {
map.set(key, key);
} else {
Expand Down Expand Up @@ -359,7 +357,7 @@ function join(output, separator) {
function spliceOne(list, index) {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
ArrayPrototypePop(list);
list.pop();
}

const kNodeModulesRE = /^(.*)[\\/]node_modules[\\/]/;
Expand Down
3 changes: 1 addition & 2 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
'use strict';

const {
MathTrunc,
ObjectCreate,
ObjectDefineProperty,
SymbolToPrimitive
Expand Down Expand Up @@ -97,7 +96,7 @@ function unenroll(item) {
// That function could then be used by http and other similar modules.
if (item[kRefed]) {
// Compliment truncation during insert().
const msecs = MathTrunc(item._idleTimeout);
const msecs = Math.trunc(item._idleTimeout);
const list = timerListMap[msecs];
if (list !== undefined && L.isEmpty(list)) {
debug('unenroll: list empty');
Expand Down