Skip to content

Commit a811a4e

Browse files
gadialraynelfss
andauthored
Apply suggestions from code review
Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>
1 parent d30189e commit a811a4e

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

crates/circuit/src/parameter/parameter_expression.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl ParameterExpression {
137137
qpy_replay(self, &self.name_map, &mut replay);
138138
replay
139139
}
140+
#[inline]
140141
pub fn num_of_symbols(&self) -> usize {
141142
self.name_map.len()
142143
}
@@ -265,10 +266,7 @@ impl ParameterExpression {
265266
subs_operations: Option<Vec<(usize, HashMap<Symbol, ParameterExpression>)>>,
266267
additional_symbols: Option<&HashSet<Symbol>>,
267268
) -> Result<Self, ParameterError> {
268-
let mut symbols = match additional_symbols {
269-
None => HashSet::new(),
270-
Some(symbol_map) => symbol_map.clone(),
271-
};
269+
let mut symbols = additional_symbols.unwrap_or_default();
272270
// the stack contains the latest lhs and rhs values
273271
let mut stack: Vec<ParameterExpression> = Vec::new();
274272
let subs_operations = subs_operations.unwrap_or_default();

crates/qpy/src/params.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ pub(crate) fn unpack_parameter_expression(
498498
replay.push(OPReplay { op, lhs, rhs });
499499
};
500500
}
501-
// let additional_symbols = HashSet::new();
502501
let additional_symbols = HashSet::from_iter(param_uuid_map.values().filter_map(|v| match v {
503502
GenericValue::ParameterExpressionSymbol(s) => Some(s.clone()),
504503
_ => None,
@@ -619,7 +618,7 @@ pub(crate) fn unpack_parameter_vector(
619618
}
620619

621620
// exp should be a symbol (for parameter/parameter vector element)
622-
// but more than that: it should no contain other symbols in its symbol table
621+
// but more than that: it should not contain other symbols in its symbol table
623622
// since if, e.g. exp was `0*x+y` and got simplified to `y` we still need
624623
// to store `x`, so we must treat exp as an expression
625624
fn expression_as_single_symbol(exp: &ParameterExpression) -> Option<Symbol> {

0 commit comments

Comments
 (0)