Browse Source

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>
canary-base
Ruben Bridgewater 8 years ago
parent
commit
01652ccc68
No known key found for this signature in database GPG Key ID: F07496B3EB3C1762
  1. 15
      lib/internal/util.js

15
lib/internal/util.js

@ -257,6 +257,20 @@ function promisify(original) {
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 = {
assertCrypto,
cachedResult,
@ -270,6 +284,7 @@ module.exports = {
normalizeEncoding,
objectToString,
promisify,
join,
// Symbol used to customize promisify conversion
customPromisifyArgs: kCustomPromisifyArgsSymbol,

Loading…
Cancel
Save