Skip to content

Reduce monomorphization by dispatching over unsigned integer widths#8110

Open
joseph-isaacs wants to merge 1 commit into
developfrom
claude/sweet-darwin-yJGOa
Open

Reduce monomorphization by dispatching over unsigned integer widths#8110
joseph-isaacs wants to merge 1 commit into
developfrom
claude/sweet-darwin-yJGOa

Conversation

@joseph-isaacs
Copy link
Copy Markdown
Contributor

@joseph-isaacs joseph-isaacs commented May 26, 2026

Summary

This PR reduces code bloat from generic monomorphization by dispatching over unsigned integer widths (4 types) instead of all signed and unsigned integer types (8 types) in hot paths where values are known to be non-negative.

The key insight is that offsets, indices, lengths, and similar values are always non-negative. By reinterpreting signed buffers as their unsigned counterparts (same width, identical bit patterns), we can dispatch over 4 unsigned widths instead of 8 integer types. For nested matches (e.g., offset type × size type), this reduces the cross-product from 8×8=64 to 4×4=16 monomorphizations.

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

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant