Skip to content

Commit

Permalink
lib: remove unused join from internal/util
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Nov 24, 2022
1 parent a01dbf1 commit db00cde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
16 changes: 0 additions & 16 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,21 +385,6 @@ function promisify(original) {

promisify.custom = kCustomPromisifiedSymbol;

// The built-in Array#join is slower in v8 6.0
function join(output, separator) {
let str = '';
if (output.length !== 0) {
const lastIndex = output.length - 1;
for (let i = 0; i < lastIndex; i++) {
// It is faster not to use a template string here
str += output[i];
str += separator;
}
str += output[lastIndex];
}
return str;
}

// As of V8 6.6, depending on the size of the array, this is anywhere
// between 1.5-10x faster than the two-arg version of Array#splice()
function spliceOne(list, index) {
Expand Down Expand Up @@ -579,7 +564,6 @@ module.exports = {
getSystemErrorName,
isError,
isInsideNodeModules,
join,
lazyDOMException,
lazyDOMExceptionClass,
normalizeEncoding,
Expand Down
9 changes: 4 additions & 5 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const {
const {
customInspectSymbol,
isError,
join,
removeColors
} = require('internal/util');

Expand Down Expand Up @@ -2057,7 +2056,7 @@ function reduceToSingleString(
const start = output.length + ctx.indentationLvl +
braces[0].length + base.length + 10;
if (isBelowBreakLength(ctx, output, start, base)) {
const joinedOutput = join(output, ', ');
const joinedOutput = ArrayPrototypeJoin(output, ', ');
if (!StringPrototypeIncludes(joinedOutput, '\n')) {
return `${base ? `${base} ` : ''}${braces[0]} ${joinedOutput}` +
` ${braces[1]}`;
Expand All @@ -2068,12 +2067,12 @@ function reduceToSingleString(
// Line up each entry on an individual line.
const indentation = `\n${StringPrototypeRepeat(' ', ctx.indentationLvl)}`;
return `${base ? `${base} ` : ''}${braces[0]}${indentation} ` +
`${join(output, `,${indentation} `)}${indentation}${braces[1]}`;
`${ArrayPrototypeJoin(output, `,${indentation} `)}${indentation}${braces[1]}`;
}
// Line up all entries on a single line in case the entries do not exceed
// `breakLength`.
if (isBelowBreakLength(ctx, output, 0, base)) {
return `${braces[0]}${base ? ` ${base}` : ''} ${join(output, ', ')} ` +
return `${braces[0]}${base ? ` ${base}` : ''} ${ArrayPrototypeJoin(output, ', ')} ` +
braces[1];
}
const indentation = StringPrototypeRepeat(' ', ctx.indentationLvl);
Expand All @@ -2083,7 +2082,7 @@ function reduceToSingleString(
const ln = base === '' && braces[0].length === 1 ?
' ' : `${base ? ` ${base}` : ''}\n${indentation} `;
// Line up each entry on an individual line.
return `${braces[0]}${ln}${join(output, `,\n${indentation} `)} ${braces[1]}`;
return `${braces[0]}${ln}${ArrayPrototypeJoin(output, `,\n${indentation} `)} ${braces[1]}`;
}

function hasBuiltInToString(value) {
Expand Down

0 comments on commit db00cde

Please sign in to comment.