Skip to content

Commit d737dfe

Browse files
authored
Inline InCB=Linker checking (#115)
1 parent 9d482aa commit d737dfe

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

.changeset/two-ideas-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"unicode-segmenter": patch
3+
---
4+
5+
Inlined the InCB=Linker checking for Indic scripts

README.md

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

216216
| Name | Unicode® | ESM? | Size | Size (min) | Size (min+gzip) | Size (min+br) | Size (min+zstd) |
217217
|------------------------------|----------|------|----------:|-----------:|----------------:|--------------:|----------------:|
218-
| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 10,774 | 6,675 | 3,368 | 2,755 | 3,497 |
218+
| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 10,708 | 6,659 | 3,363 | 2,739 | 3,490 |
219219
| `graphemer` | 15.0.0 | ✖️ ️| 410,435 | 95,104 | 15,752 | 10,660 | 15,911 |
220220
| `grapheme-splitter` | 10.0.0 | ✖️ | 122,254 | 23,682 | 7,852 | 4,802 | 6,753 |
221221
| `@formatjs/intl-segmenter`* | 15.0.0 | ✖️ | 603,510 | 369,673 | 72,273 | 49,530 | 68,027 |
@@ -231,7 +231,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb
231231

232232
| Name | Bytecode size | Bytecode size (gzip)* |
233233
|------------------------------|--------------:|----------------------:|
234-
| `unicode-segmenter/grapheme` | 20,295 | 11,420 |
234+
| `unicode-segmenter/grapheme` | 20,259 | 11,417 |
235235
| `graphemer` | 134,089 | 31,766 |
236236
| `grapheme-splitter` | 63,946 | 19,162 |
237237

src/grapheme.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@ export function* graphemeSegments(input) {
167167
consonant = isIndicConjunctConsonant(_hd);
168168
}
169169
if (consonant && catAfter === 3) {
170-
linker = linker || isIndicConjunctLinker(cp);
170+
linker = linker
171+
|| cp === 0x094D
172+
|| cp === 0x09CD
173+
|| cp === 0x0A4D
174+
|| cp === 0x0ACD
175+
|| cp === 0x0B4D
176+
|| cp === 0x0C4D
177+
|| cp === 0x0D4D;
171178
} else {
172179
linker = false;
173180
}
@@ -339,18 +346,3 @@ function cat(cp) {
339346
function isIndicConjunctConsonant(cp) {
340347
return findUnicodeRangeIndex(cp, consonant_ranges) >= 0;
341348
}
342-
343-
/**
344-
* @param {number} cp
345-
* @return {boolean}
346-
*/
347-
function isIndicConjunctLinker(cp) {
348-
return (
349-
cp === 2381 /* 0x094D */ ||
350-
cp === 2509 /* 0x09CD */ ||
351-
cp === 2765 /* 0x0ACD */ ||
352-
cp === 2893 /* 0x0B4D */ ||
353-
cp === 3149 /* 0x0C4D */ ||
354-
cp === 3405 /* 0x0D4D */
355-
);
356-
}

0 commit comments

Comments
 (0)