Use a buffer instead of string concatenation in reverseIfRtl in src/core/unicode.js

This avoids creating intermediate strings and should be slightly more
efficient.
This commit is contained in:
Tim van der Meij 2021-02-27 13:18:43 +01:00
parent 24f80f1e38
commit 4e96d59fca
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -1633,11 +1633,11 @@ function reverseIfRtl(chars) {
if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
return chars;
}
let s = "";
const buf = [];
for (let ii = charsLength - 1; ii >= 0; ii--) {
s += chars[ii];
buf.push(chars[ii]);
}
return s;
return buf.join("");
}
export {