Skip to content

Commit 7e7ac3e

Browse files
committed
test
1 parent 3d23120 commit 7e7ac3e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/grapheme.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ export function* graphemeSegments(input) {
7474
/** InCB=Linker */
7575
let linker = false;
7676

77-
/** InCB=Consonant InCB=Linker x InCB=Consonant */
78-
let incb = false;
79-
8077
let index = 0;
8178

8279
/** Beginning category of a segment */
@@ -86,6 +83,9 @@ export function* graphemeSegments(input) {
8683
let _hd = cp;
8784

8885
while (cursor < len) {
86+
/** InCB=Consonant InCB=Linker x InCB=Consonant */
87+
let incb = false;
88+
8989
cp = /** @type {number} */ (input.codePointAt(cursor));
9090
catAfter = cat(cp);
9191

@@ -100,10 +100,8 @@ export function* graphemeSegments(input) {
100100
emoji = true;
101101

102102
} else if (catAfter === 0 /* Any */) {
103-
// Note: Put GB9c rule checking here to reduce.
104-
incb = consonant && linker && (consonant = isIndicConjunctConsonant(cp));
105-
// It cannot be both a linker and a consonant.
106-
linker = linker && !consonant;
103+
incb = consonant && linker && isIndicConjunctConsonant(cp);
104+
linker = false;
107105
}
108106
}
109107

@@ -119,16 +117,19 @@ export function* graphemeSegments(input) {
119117

120118
// flush
121119
emoji = false;
122-
incb = false;
120+
consonant = false;
121+
linker = false;
123122
index = cursor;
124123
_catBegin = catAfter;
125124
_hd = cp;
126-
} else if (cp >= 2325 && cp <= 3386) {
125+
126+
// Note: Avoid InCB state checking much as possible
127+
} else if (_hd >= 2325 && _hd <= 3386) {
127128
// Update InCB state only when continuing within a segment
128-
if (!consonant && catBefore === 0)
129+
if (!consonant)
129130
consonant = isIndicConjunctConsonant(_hd);
130131
if (catAfter === 3 /* Extend */)
131-
linker = linker || isIndicConjunctLinker(cp);
132+
linker = isIndicConjunctLinker(cp);
132133
}
133134

134135
cursor += cp <= BMP_MAX ? 1 : 2;

0 commit comments

Comments
 (0)