util: add fast internal array join method
PR-URL: https://github.com/nodejs/node/pull/14881 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
6bfc439711
commit
01652ccc68
@ -257,6 +257,20 @@ function promisify(original) {
|
|||||||
|
|
||||||
promisify.custom = kCustomPromisifiedSymbol;
|
promisify.custom = kCustomPromisifiedSymbol;
|
||||||
|
|
||||||
|
// The build-in Array#join is slower in v8 6.0
|
||||||
|
function join(output, separator) {
|
||||||
|
var str = '';
|
||||||
|
if (output.length !== 0) {
|
||||||
|
for (var i = 0; i < output.length - 1; i++) {
|
||||||
|
// It is faster not to use a template string here
|
||||||
|
str += output[i];
|
||||||
|
str += separator;
|
||||||
|
}
|
||||||
|
str += output[i];
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
assertCrypto,
|
assertCrypto,
|
||||||
cachedResult,
|
cachedResult,
|
||||||
@ -270,6 +284,7 @@ module.exports = {
|
|||||||
normalizeEncoding,
|
normalizeEncoding,
|
||||||
objectToString,
|
objectToString,
|
||||||
promisify,
|
promisify,
|
||||||
|
join,
|
||||||
|
|
||||||
// Symbol used to customize promisify conversion
|
// Symbol used to customize promisify conversion
|
||||||
customPromisifyArgs: kCustomPromisifyArgsSymbol,
|
customPromisifyArgs: kCustomPromisifyArgsSymbol,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user