Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: eager resize for ´load_data´ #1117

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* perf: insert elements from the tail in `load_data` so reallocation happens only once [#1117](https://github.com/lambdaclass/cairo-rs/pull/1117)

* Use to_signed_felt as function for felt252 as BigInt within [-P/2, P/2] range and use to_bigint as function for representation as BigInt. [#1100](https://github.com/lambdaclass/cairo-rs/pull/1100)

* Implement hint on field_arithmetic lib [#1090](https://github.com/lambdaclass/cairo-rs/pull/1090)
Expand Down
4 changes: 3 additions & 1 deletion src/vm/vm_memory/memory_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ impl MemorySegmentManager {
ptr: Relocatable,
data: &Vec<MaybeRelocatable>,
) -> Result<Relocatable, MemoryError> {
for (num, value) in data.iter().enumerate() {
// Starting from the end ensures any necessary resize
// is performed once with enough room for everything
for (num, value) in data.iter().enumerate().rev() {
self.memory.insert((ptr + num)?, value)?;
}
(ptr + data.len()).map_err(MemoryError::Math)
Expand Down