1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

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 {