Fix error in charProperties optimization.

Result should be 2, not 1.
Use a static field to avoid this kind of error
(though it might be slightly slower, depending on the compiler/toolchain).
This commit is contained in:
Per Bothner
2023-06-28 15:19:44 -07:00
parent 693f6b2d14
commit dc6818de2b
@@ -14,14 +14,15 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
constructor() {
}
static readonly plainNarrowProperties: UnicodeCharProperties
= UnicodeService.createPropertyValue(UC.GRAPHEME_BREAK_Other, 1, false);
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;
return UnicodeGraphemeProvider.plainNarrowProperties;
}
let charInfo = UC.getInfo(codepoint);