diff --git a/README.md b/README.md index f58aad0..988cff8 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb | Name | Unicode® | ESM? | Size | Size (min) | Size (min+gzip) | Size (min+br) | Size (min+zstd) | |------------------------------|----------|------|----------:|-----------:|----------------:|--------------:|----------------:| -| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 15,921 | 12,189 | 5,060 | 3,773 | 4,746 | +| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 15,922 | 12,188 | 5,057 | 3,770 | 4,745 | | `graphemer` | 15.0.0 | ✖️ ️| 410,435 | 95,104 | 15,752 | 10,660 | 15,911 | | `grapheme-splitter` | 10.0.0 | ✖️ | 122,252 | 23,680 | 7,852 | 4,841 | 6,750 | | `@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 | Name | Bytecode size | Bytecode size (gzip)* | |------------------------------|--------------:|----------------------:| -| `unicode-segmenter/grapheme` | 20,928 | 10,973 | +| `unicode-segmenter/grapheme` | 20,936 | 10,980 | | `graphemer` | 133,978 | 31,713 | | `grapheme-splitter` | 63,835 | 19,137 | diff --git a/src/grapheme.js b/src/grapheme.js index 50a1363..256337f 100644 --- a/src/grapheme.js +++ b/src/grapheme.js @@ -89,11 +89,7 @@ export function* graphemeSegments(input) { let index = 0; while (true) { - // @ts-ignore - // Note: - // Using `!` and implicit conversion for brotli compression ratio. - // Even a small change like `+` or `>=` here will increase the size. - cursor += !(cp < 0xFFFF) + 1; + cursor += cp < 0xFFFF ? 1 : 2; // Note: Of course the nullish coalescing is useful here, // but avoid it for aggressive compatibility and perf claim