Optimize UnicodeGraphemeProvider for the ASCII case.

This commit is contained in:
Per Bothner
2023-05-21 10:29:13 -07:00
parent 1a8c7dad5f
commit fa89e1776b
@@ -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;