From fa89e1776b107fd602213af42c5f8dc6e722b668 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Sun, 21 May 2023 10:29:13 -0700 Subject: [PATCH] Optimize UnicodeGraphemeProvider for the ASCII case. --- .../src/UnicodeGraphemeProvider.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts b/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts index 87ec8d32..00740dac 100644 --- a/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts +++ b/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts @@ -15,6 +15,15 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider { } public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties { + // Optimize the simple ASCII case, under the condition that + // UnicodeService.extractCharKind(preceding) === GRAPHEME_BREAK_Other + // (which also covers the case that preceding === 0). + + if ((codepoint >= 32 && codepoint < 127) && (preceding >> 3) === 0) { + // Inlined UnicodeService.createPropertyValue(GRAPHEME_BREAK_Other, 1, false) + return 1; + } + let charInfo = UC.getInfo(codepoint); let w = UC.infoToWidthInfo(charInfo); let shouldJoin = false;