diff --git a/lib/internal/util.js b/lib/internal/util.js index f4c08ecdddbdaf..787e07014cfad8 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -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) { @@ -579,7 +564,6 @@ module.exports = { getSystemErrorName, isError, isInsideNodeModules, - join, lazyDOMException, lazyDOMExceptionClass, normalizeEncoding, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index abbb0d9c8ebc86..f53e1797057d7b 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -114,7 +114,6 @@ const { const { customInspectSymbol, isError, - join, removeColors } = require('internal/util'); @@ -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]}`; @@ -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); @@ -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) {