Skip to content

🧼 generate compact wcwidth tables#49

Open
natemoo-re wants to merge 8 commits into
mainfrom
ref/wcwidth
Open

🧼 generate compact wcwidth tables#49
natemoo-re wants to merge 8 commits into
mainfrom
ref/wcwidth

Conversation

@natemoo-re
Copy link
Copy Markdown
Member

Building on #35, reduces npm install size by ~12% (270 kB → 238 kB unpacked) via:

  • replaces the src/wcwidth.c implementation borrowed from termbox2 (~1,200 lines) with optimized tables generated by tasks/gen-wcwidth.ts
  • tables are generated from official Unicode spec, only tracks the size of wide characters (width = 2) and zero-width characters (width = 0) instead of all ranges (width = 0 | 1 | 2)
  • shrinks clayterm.wasm from 152 kB → 128 kB; wcwidth data was a significant portion of the binary
  • adds a gen-wcwidth task to regenerate tables when Unicode data updates

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/clayterm@49

commit: fbfc0eb

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 28, 2026

Merging this PR will degrade performance by 10.25%

❌ 1 regressed benchmark
✅ 17 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
simple text 184 µs 205.1 µs -10.25%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ref/wcwidth (fbfc0eb) with main (4139212)

Open in CodSpeed

@natemoo-re
Copy link
Copy Markdown
Member Author

Performance regression appears to be due to different hardware being selected to run the benchmarks compared to main--debugged the logs locally. Merging this should be safe.

@natemoo-re natemoo-re marked this pull request as ready for review May 28, 2026 19:42
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