-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I think there is still some performance to gain.
e.g. currently you have to create a variable lastIndex.
Some ideas.
const empty = "";
function join(output, separator = ",") {
const length = output.length
if (length === 0) {
return empty;
}
let str = empty;
let i = 1
while (i < length) {
// It is faster not to use a template string here
str += separator;
str += output[i++];
}
return output[0] + str
}function join(array, separator) {
const length = array.length
if (length === 0) {
return "";
} else if (length === 1) {
return array[0];
} else {
let str = "";
let i = 1;
while (i < length) {
// It is faster not to use a template string here
str += separator;
str += array[i++];
}
return array[0] + str;
}
}Or something with a switch.
Metadata
Metadata
Assignees
Labels
No labels