feat: Optimize View::view_public_input to avoid temporary Vec allocation#543
Closed
VolodymyrBg wants to merge 1 commit intonexus-xyz:mainfrom
Closed
feat: Optimize View::view_public_input to avoid temporary Vec allocation#543VolodymyrBg wants to merge 1 commit intonexus-xyz:mainfrom
VolodymyrBg wants to merge 1 commit intonexus-xyz:mainfrom
Conversation
Contributor
|
I think this is fine, the helper function is just a lot cleaner. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.