Skip to content

Commit

Permalink
Remove redundant function. (#2068)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Nov 11, 2024
1 parent 7617214 commit ff054af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
12 changes: 6 additions & 6 deletions executor/src/witgen/machines/fixed_lookup_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::witgen::global_constraints::{GlobalConstraints, RangeConstraintSet};
use crate::witgen::processor::OuterQuery;
use crate::witgen::range_constraints::RangeConstraint;
use crate::witgen::rows::RowPair;
use crate::witgen::util::try_to_simple_poly_ref;
use crate::witgen::util::try_to_simple_poly;
use crate::witgen::{EvalError, EvalValue, IncompleteCause, MutableState, QueryCallback};
use crate::witgen::{EvalResult, FixedData};

Expand Down Expand Up @@ -58,7 +58,7 @@ fn create_index<T: FieldElement>(
let (input_fixed_columns, output_fixed_columns): (Vec<_>, Vec<_>) = right
.expressions
.iter()
.map(|e| try_to_simple_poly_ref(e).unwrap().poly_id)
.map(|e| try_to_simple_poly(e).unwrap().poly_id)
.zip(&application.inputs)
.partition_map(|(poly_id, is_input)| {
if is_input {
Expand Down Expand Up @@ -165,7 +165,7 @@ impl<'a, T: FieldElement> FixedLookup<'a, T> {
connection.is_lookup()
&& connection.right.selector.is_one()
&& connection.right.expressions.iter().all(|e| {
try_to_simple_poly_ref(e)
try_to_simple_poly(e)
.map(|poly| poly.poly_id.ptype == PolynomialType::Constant)
.unwrap_or(false)
})
Expand Down Expand Up @@ -304,7 +304,7 @@ fn unique_size<T: FieldElement>(
.right
.expressions
.iter()
.map(|expr| try_to_simple_poly_ref(expr).unwrap().poly_id)
.map(|expr| try_to_simple_poly(expr).unwrap().poly_id)
.collect::<Vec<_>>();
fixed_columns
.iter()
Expand Down Expand Up @@ -339,7 +339,7 @@ impl<'a, T: FieldElement> Machine<'a, T> for FixedLookup<'a, T> {
let right = right
.expressions
.iter()
.map(|e| try_to_simple_poly_ref(e).unwrap())
.map(|e| try_to_simple_poly(e).unwrap())
.peekable();

let outer_query = OuterQuery::new(caller_rows, identity);
Expand Down Expand Up @@ -389,7 +389,7 @@ impl<'a, T: FieldElement> Machine<'a, T> for FixedLookup<'a, T> {
.zip(&right.expressions)
.filter_map(|(l, r)| match l {
LookupCell::Input(v) => {
let name = try_to_simple_poly_ref(r).unwrap().name.clone();
let name = try_to_simple_poly(r).unwrap().name.clone();
Some((name, **v))
}
_ => None,
Expand Down
22 changes: 5 additions & 17 deletions executor/src/witgen/util.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference};
use powdr_ast::analyzed::{AlgebraicExpression, AlgebraicReference};

/// Checks if an expression is
/// - a polynomial
/// - not part of a polynomial array
/// - not shifted with `'`
///
/// and return the polynomial if so
pub fn try_to_simple_poly<T>(expr: &Expression<T>) -> Option<&AlgebraicReference> {
if let Expression::Reference(p @ AlgebraicReference { next: false, .. }) = expr {
/// Checks if an algebraic expression just a polynomial / column reference without "next"
/// and returns the polynomial if so
pub fn try_to_simple_poly<T>(expr: &AlgebraicExpression<T>) -> Option<&AlgebraicReference> {
if let AlgebraicExpression::Reference(p @ AlgebraicReference { next: false, .. }) = expr {
Some(p)
} else {
None
}
}

pub fn try_to_simple_poly_ref<T>(expr: &Expression<T>) -> Option<&AlgebraicReference> {
if let Expression::Reference(poly_ref) = expr {
(!poly_ref.next).then_some(poly_ref)
} else {
None
}
}

0 comments on commit ff054af

Please sign in to comment.