Skip to content

Commit db00cde

Browse files
committed
lib: remove unused join from internal/util
1 parent a01dbf1 commit db00cde

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

lib/internal/util.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -385,21 +385,6 @@ function promisify(original) {
385385

386386
promisify.custom = kCustomPromisifiedSymbol;
387387

388-
// The built-in Array#join is slower in v8 6.0
389-
function join(output, separator) {
390-
let str = '';
391-
if (output.length !== 0) {
392-
const lastIndex = output.length - 1;
393-
for (let i = 0; i < lastIndex; i++) {
394-
// It is faster not to use a template string here
395-
str += output[i];
396-
str += separator;
397-
}
398-
str += output[lastIndex];
399-
}
400-
return str;
401-
}
402-
403388
// As of V8 6.6, depending on the size of the array, this is anywhere
404389
// between 1.5-10x faster than the two-arg version of Array#splice()
405390
function spliceOne(list, index) {
@@ -579,7 +564,6 @@ module.exports = {
579564
getSystemErrorName,
580565
isError,
581566
isInsideNodeModules,
582-
join,
583567
lazyDOMException,
584568
lazyDOMExceptionClass,
585569
normalizeEncoding,

lib/internal/util/inspect.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ const {
114114
const {
115115
customInspectSymbol,
116116
isError,
117-
join,
118117
removeColors
119118
} = require('internal/util');
120119

@@ -2057,7 +2056,7 @@ function reduceToSingleString(
20572056
const start = output.length + ctx.indentationLvl +
20582057
braces[0].length + base.length + 10;
20592058
if (isBelowBreakLength(ctx, output, start, base)) {
2060-
const joinedOutput = join(output, ', ');
2059+
const joinedOutput = ArrayPrototypeJoin(output, ', ');
20612060
if (!StringPrototypeIncludes(joinedOutput, '\n')) {
20622061
return `${base ? `${base} ` : ''}${braces[0]} ${joinedOutput}` +
20632062
` ${braces[1]}`;
@@ -2068,12 +2067,12 @@ function reduceToSingleString(
20682067
// Line up each entry on an individual line.
20692068
const indentation = `\n${StringPrototypeRepeat(' ', ctx.indentationLvl)}`;
20702069
return `${base ? `${base} ` : ''}${braces[0]}${indentation} ` +
2071-
`${join(output, `,${indentation} `)}${indentation}${braces[1]}`;
2070+
`${ArrayPrototypeJoin(output, `,${indentation} `)}${indentation}${braces[1]}`;
20722071
}
20732072
// Line up all entries on a single line in case the entries do not exceed
20742073
// `breakLength`.
20752074
if (isBelowBreakLength(ctx, output, 0, base)) {
2076-
return `${braces[0]}${base ? ` ${base}` : ''} ${join(output, ', ')} ` +
2075+
return `${braces[0]}${base ? ` ${base}` : ''} ${ArrayPrototypeJoin(output, ', ')} ` +
20772076
braces[1];
20782077
}
20792078
const indentation = StringPrototypeRepeat(' ', ctx.indentationLvl);
@@ -2083,7 +2082,7 @@ function reduceToSingleString(
20832082
const ln = base === '' && braces[0].length === 1 ?
20842083
' ' : `${base ? ` ${base}` : ''}\n${indentation} `;
20852084
// Line up each entry on an individual line.
2086-
return `${braces[0]}${ln}${join(output, `,\n${indentation} `)} ${braces[1]}`;
2085+
return `${braces[0]}${ln}${ArrayPrototypeJoin(output, `,\n${indentation} `)} ${braces[1]}`;
20872086
}
20882087

20892088
function hasBuiltInToString(value) {

0 commit comments

Comments
 (0)