Skip to content

Commit 4bac8b5

Browse files
committed
Changeset: Use string concatenation instead of array join
People report that string concatenation is faster.
1 parent 16b714d commit 4bac8b5

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/static/js/Changeset.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -726,22 +726,14 @@ exports.stringIterator = (str) => {
726726
/**
727727
* @returns {StringAssembler}
728728
*/
729-
exports.stringAssembler = () => {
730-
const pieces = [];
731-
729+
exports.stringAssembler = () => ({
730+
_str: '',
732731
/**
733732
* @param {string} x -
734733
*/
735-
const append = (x) => {
736-
pieces.push(String(x));
737-
};
738-
739-
const toString = () => pieces.join('');
740-
return {
741-
append,
742-
toString,
743-
};
744-
};
734+
append(x) { this._str += String(x); },
735+
toString() { return this._str; },
736+
});
745737

746738
/**
747739
* Class to iterate and modify texts which have several lines. It is used for applying Changesets on

0 commit comments

Comments
 (0)