Skip to content

Commit 4da4a8b

Browse files
committed
use shorthand syntax
1 parent 3c753c1 commit 4da4a8b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb
220220

221221
| Name | Unicode® | ESM? | Size | Size (min) | Size (min+gzip) | Size (min+br) | Size (min+zstd) |
222222
|------------------------------|----------|------|----------:|-----------:|----------------:|--------------:|----------------:|
223-
| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 15,625 | 12,166 | 5,044 | 3,752 | 4,724 |
223+
| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 15,607 | 12,166 | 5,042 | 3,747 | 4,725 |
224224
| `graphemer` | 15.0.0 | ✖️ ️| 410,435 | 95,104 | 15,752 | 10,660 | 15,911 |
225225
| `grapheme-splitter` | 10.0.0 | ✖️ | 122,252 | 23,680 | 7,852 | 4,841 | 6,750 |
226226
| `@formatjs/intl-segmenter`* | 15.0.0 | ✖️ | 603,285 | 369,560 | 72,218 | 49,416 | 67,975 |
@@ -236,7 +236,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb
236236

237237
| Name | Bytecode size | Bytecode size (gzip)* |
238238
|------------------------------|--------------:|----------------------:|
239-
| `unicode-segmenter/grapheme` | 20,932 | 10,994 |
239+
| `unicode-segmenter/grapheme` | 20,932 | 10,991 |
240240
| `graphemer` | 133,978 | 31,713 |
241241
| `grapheme-splitter` | 63,835 | 19,137 |
242242

src/grapheme.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ export function* graphemeSegments(input) {
6060
/** Category of codepoint immediately preceding cursor */
6161
let catBefore = cat(cp, cache);
6262

63-
/** Beginning category of a segment */
64-
let catBegin = catBefore;
65-
6663
/** @type {GraphemeCategoryNum | null} Category of codepoint immediately preceding cursor. */
6764
let catAfter = null;
6865

@@ -81,11 +78,14 @@ export function* graphemeSegments(input) {
8178
/** InCB=Consonant InCB=Linker x InCB=Consonant */
8279
let incb = false;
8380

81+
let index = 0;
82+
83+
/** Beginning category of a segment */
84+
let _catBegin = catBefore;
85+
8486
/** Memoize the beginnig code point a the segment. */
8587
let _hd = cp;
8688

87-
let index = 0;
88-
8989
while (true) {
9090
cursor += cp < 0xFFFF ? 1 : 2;
9191

@@ -95,7 +95,7 @@ export function* graphemeSegments(input) {
9595
index,
9696
input,
9797
_hd,
98-
_catBegin: catBegin,
98+
_catBegin,
9999
_catEnd: catBefore,
100100
};
101101
return;
@@ -139,15 +139,15 @@ export function* graphemeSegments(input) {
139139
index,
140140
input,
141141
_hd,
142-
_catBegin: catBegin,
142+
_catBegin,
143143
_catEnd: catBefore,
144144
};
145145

146146
// flush
147-
index = cursor;
148147
emoji = false;
149148
incb = false;
150-
catBegin = catAfter;
149+
index = cursor;
150+
_catBegin = catAfter;
151151
_hd = cp;
152152
}
153153

0 commit comments

Comments
 (0)