Skip to content

Commit

Permalink
perf: eager resize for ´load_data´ (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oppen authored May 5, 2023
1 parent c035797 commit e284753
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#### Upcoming Changes

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

* Add `CairoRunner::get_program method` [#1123](https://github.com/lambdaclass/cairo-rs/pull/1123)

* 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)

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

0 comments on commit e284753

Please sign in to comment.