Skip to content

add collectGraphemes() as a fast method#141

Merged
cometkim merged 4 commits into
mainfrom
split-to-array
Jul 22, 2026
Merged

add collectGraphemes() as a fast method#141
cometkim merged 4 commits into
mainfrom
split-to-array

Conversation

@cometkim

Copy link
Copy Markdown
Owner

Building a grapheme array is the most common use case for this library.

Added a new method to its direct path. It directly assigns a segment of text to a buffer to avoid extra overhead from the generator/iterator protocol.

It's 2-4x faster than the generator version. But it may consume memory too eagerly with large input.

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 133edc6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
unicode-segmenter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unicode-segmenter@141

commit: 133edc6

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
🆕 6 new benchmarks
⏩ 12 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 collectGraphemes - Code snippet (combined) N/A 89.2 µs N/A
🆕 collectGraphemes - Demonic characters N/A 22.6 µs N/A
🆕 collectGraphemes - Emojis N/A 26 µs N/A
🆕 collectGraphemes - Hindi N/A 40.1 µs N/A
🆕 collectGraphemes - Lorem ipsum (ascii) N/A 37.7 µs N/A
🆕 collectGraphemes - Tweet text (combined) N/A 46.8 µs N/A

Comparing split-to-array (133edc6) with main (56580cb)

Open in CodSpeed

Footnotes

  1. 12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cometkim cometkim changed the title add splitGraphemesToArray() as a fast method add collectGraphemes() as a fast method Jul 22, 2026
@cometkim
cometkim merged commit e94d203 into main Jul 22, 2026
4 checks passed
@cometkim
cometkim deleted the split-to-array branch July 22, 2026 10:02
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (56580cb) to head (133edc6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #141   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          973      1033   +60     
=========================================
+ Hits           973      1033   +60     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant