Skip to content

Commit

Permalink
Use BTreeSet for assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Jan 14, 2025
1 parent 0e9928c commit 2d9ce28
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions executor/src/witgen/jit/witgen_inference.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
collections::{HashMap, HashSet},
collections::{BTreeSet, HashMap, HashSet},
fmt::{Display, Formatter},
};

Expand Down Expand Up @@ -37,7 +37,7 @@ pub struct WitgenInference<'a, T: FieldElement, FixedEval> {
/// connection on the same row.
complete_identities: HashSet<(u64, i32)>,
/// Internal equality constraints that are not identities from the constraint set.
assignments: Vec<Assignment<'a, T>>,
assignments: BTreeSet<Assignment<'a, T>>,
code: Vec<Effect<T, Variable>>,
}

Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator<T>> WitgenInference<'a, T, F
/// This does not have to be solvable right away, but is always processed as soon as we have progress.
/// Note that all variables in the expression can be unknown and their status can also change over time.
pub fn assign_constant(&mut self, expression: &'a Expression<T>, row_offset: i32, value: T) {
self.assignments.push(Assignment {
self.assignments.insert(Assignment {
lhs: expression,
row_offset,
rhs: VariableOrValue::Value(value),
Expand All @@ -198,7 +198,7 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator<T>> WitgenInference<'a, T, F
row_offset: i32,
variable: Variable,
) {
self.assignments.push(Assignment {
self.assignments.insert(Assignment {
lhs: expression,
row_offset,
rhs: VariableOrValue::Variable(variable),
Expand Down Expand Up @@ -568,14 +568,14 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator<T>> Evaluator<'a, T, FixedEv

/// An equality constraint between an algebraic expression evaluated
/// on a certain row offset and a variable or fixed constant value.
#[derive(Clone)]
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
struct Assignment<'a, T: FieldElement> {
lhs: &'a Expression<T>,
row_offset: i32,
rhs: VariableOrValue<T, Variable>,
}

#[derive(Clone, derive_more::Display)]
#[derive(Clone, derive_more::Display, Ord, PartialOrd, Eq, PartialEq, Debug)]
enum VariableOrValue<T, V> {
Variable(V),
Value(T),
Expand Down

0 comments on commit 2d9ce28

Please sign in to comment.