From 4e96d59fca600cc51224c7a68850a7e560fb145b Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 27 Feb 2021 13:18:43 +0100 Subject: [PATCH] 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. --- src/core/unicode.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/unicode.js b/src/core/unicode.js index 4027ef8eb..b9623308c 100644 --- a/src/core/unicode.js +++ b/src/core/unicode.js @@ -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 {