Skip to content

feat: Optimize View::view_public_input to avoid temporary Vec allocation#543

Closed
VolodymyrBg wants to merge 1 commit intonexus-xyz:mainfrom
VolodymyrBg:feat/optimize
Closed

feat: Optimize View::view_public_input to avoid temporary Vec allocation#543
VolodymyrBg wants to merge 1 commit intonexus-xyz:mainfrom
VolodymyrBg:feat/optimize

Conversation

@VolodymyrBg
Copy link
Contributor

The previous implementation of View::view_public_input() filtered self.input_memory and collected into a temporary Vec before converting to bytes via io_entries_into_vec, incurring an unnecessary allocation and copy. Given that LinearEmulator::finalize() constructs input_memory as a contiguous, ordered per-byte coverage of the public input range, we can deterministically size the output as (end - start) and fill it directly. This change removes the intermediate collection by computing start and end from LinearMemoryLayout, pre-allocating the output buffer accordingly, and writing into it in a single pass over self.input_memory.

@sjudson
Copy link
Contributor

sjudson commented Nov 25, 2025

I think this is fine, the helper function is just a lot cleaner.

@sjudson sjudson closed this Nov 25, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants