Skip to content

Commit

Permalink
Improve performance of AbstractInstructionSet::verify(self) (FuelLa…
Browse files Browse the repository at this point in the history
…bs#3898)

This brings down the call to `AbstractInstructionSet::verify(self)` from
> `70s` to `30ms` (> 2000X improvement) in
https://github.com/sway-libs/concentrated-liquidity/

Co-authored-by: João Matos <[email protected]>
  • Loading branch information
mohammadfawaz and tritao authored Jan 26, 2023
1 parent 61d96de commit dd95780
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sway-core/src/asm_generation/fuel/abstract_instruction_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use crate::{
use sway_error::error::CompileError;
use sway_types::Span;

use std::{
collections::{BTreeSet, HashSet},
fmt,
};
use std::{collections::HashSet, fmt};

use either::Either;

Expand Down Expand Up @@ -134,12 +131,12 @@ impl AbstractInstructionSet {
($regs: expr, $set: expr) => {
let mut regs = $regs;
regs.retain(|&reg| matches!(reg, VirtualRegister::Virtual(_)));
$set.append(&mut regs);
$set.extend(regs.into_iter());
};
}

let mut use_regs = BTreeSet::new();
let mut def_regs = BTreeSet::new();
let mut use_regs = HashSet::new();
let mut def_regs = HashSet::new();
for op in &self.ops {
add_virt_regs!(op.use_registers(), use_regs);
add_virt_regs!(op.def_registers(), def_regs);
Expand Down

0 comments on commit dd95780

Please sign in to comment.