Skip to content

Support documented Proc width overwrites - #37

Open
OskarEichler wants to merge 2 commits into
janlelis:mainfrom
OskarEichler:codex/support-proc-overwrites
Open

OskarEichler wants to merge 2 commits into
janlelis:mainfrom
OskarEichler:codex/support-proc-overwrites

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

The README documents Proc values for overwrite:, but the current empty-check calls Proc#empty? and raises. Accept non-collection lookup objects and retain the empty-Hash fast path. Cache each lookup as well, preventing stateful Proc values from being evaluated twice for one codepoint.

Verified with the full 67-example suite and a focused Proc/lookup-count model on Ruby 4.0.6 and 3.2.11.

@janlelis

janlelis commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Looks good, but can you add a few test cases? If overwrite is not passed, nil, false, or an empty? object, do optimize. If it is hash, proc, or otherwise non-empty, apply overrides

@OskarEichler

Copy link
Copy Markdown
Contributor Author

Added the requested cases in cd0824a. Specs assert that custom processing is skipped for omitted/nil/false/empty overwrites, while non-empty hashes, Procs, and lookup objects apply the override. Full suite on Ruby 4.0.6: 69 examples, zero failures; git diff --check passes.

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.

2 participants