Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unused join from internal/util #45600

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
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