Skip to content

Commit 0ded191

Browse files
committed
Changeset: Use string concatenation instead of array join
People report that string concatenation is faster.
1 parent c7cbf8d commit 0ded191

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
@@ -677,19 +677,11 @@ exports.stringIterator = (str) => {
677677
/**
678678
* A custom made StringBuffer
679679
*/
680-
exports.stringAssembler = () => {
681-
const pieces = [];
682-
683-
const append = (x) => {
684-
pieces.push(String(x));
685-
};
686-
687-
const toString = () => pieces.join('');
688-
return {
689-
append,
690-
toString,
691-
};
692-
};
680+
exports.stringAssembler = () => ({
681+
_str: '',
682+
append(x) { this._str += String(x); },
683+
toString() { return this._str; },
684+
});
693685

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

0 commit comments

Comments
 (0)