Skip to content

Commit 3e5f3d9

Browse files
authored
remove conversion hack on counting (#87)
which was introduced because of some advantages in content compression. It's simply not useful anymore.
1 parent f95b676 commit 3e5f3d9

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
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,921 | 12,189 | 5,060 | 3,773 | 4,746 |
223+
| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 15,922 | 12,188 | 5,057 | 3,770 | 4,745 |
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,928 | 10,973 |
239+
| `unicode-segmenter/grapheme` | 20,936 | 10,980 |
240240
| `graphemer` | 133,978 | 31,713 |
241241
| `grapheme-splitter` | 63,835 | 19,137 |
242242

src/grapheme.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ export function* graphemeSegments(input) {
8989
let index = 0;
9090

9191
while (true) {
92-
// @ts-ignore
93-
// Note:
94-
// Using `!` and implicit conversion for brotli compression ratio.
95-
// Even a small change like `+` or `>=` here will increase the size.
96-
cursor += !(cp < 0xFFFF) + 1;
92+
cursor += cp < 0xFFFF ? 1 : 2;
9793

9894
// Note: Of course the nullish coalescing is useful here,
9995
// but avoid it for aggressive compatibility and perf claim

0 commit comments

Comments
 (0)