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

chore: Optmize update_acir() #2476

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions crates/noirc_errors/src/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use acvm::compiler::AcirTransformationMap;
use serde_with::serde_as;
use serde_with::DisplayFromStr;
use std::collections::BTreeMap;
use std::mem;

use crate::Location;
use serde::{Deserialize, Serialize};
Expand All @@ -29,16 +30,13 @@ impl DebugInfo {
/// renders the old `OpcodeLocation`s invalid. The AcirTransformationMap is able to map the old `OpcodeLocation` to the new ones.
/// Note: One old `OpcodeLocation` might have transformed into more than one new `OpcodeLocation`.
pub fn update_acir(&mut self, update_map: AcirTransformationMap) {
let mut new_locations_map = BTreeMap::new();
let old_locations = mem::take(&mut self.locations);

for (old_opcode_location, source_locations) in &self.locations {
let new_opcode_locations = update_map.new_locations(*old_opcode_location);
for new_opcode_location in new_opcode_locations {
new_locations_map.insert(new_opcode_location, source_locations.clone());
}
for (old_opcode_location, source_locations) in old_locations {
let _ = update_map.new_locations(old_opcode_location).map(|new_opcode_location| {
self.locations.insert(new_opcode_location, source_locations.clone());
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
});
}

self.locations = new_locations_map;
}

pub fn opcode_location(&self, loc: &OpcodeLocation) -> Option<Vec<Location>> {
Expand Down