--- a/crates/jrsonnet-evaluator/src/arr/mod.rs +++ b/crates/jrsonnet-evaluator/src/arr/mod.rs @@ -145,6 +145,9 @@ } /// Returns None if get is either non cheap, or out of bounds + /// Note that non-cheap access includes errorable values + /// + /// Prefer it to `get_lazy`, but use `get` when you can. fn get_cheap(&self, index: usize) -> Option { self.0.get_cheap(index) } @@ -165,6 +168,7 @@ (0..self.len()).map(|i| self.get_lazy(i).expect("length checked")) } + /// Prefer it over `iter_lazy`, but do not use it where `iter` will do. pub fn iter_cheap(&self) -> Option + '_> { if self.is_cheap() { Some((0..self.len()).map(|i| self.get_cheap(i).expect("length and is_cheap checked"))) --- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs +++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs @@ -98,22 +98,13 @@ #[cfg(feature = "exp-bigint")] (BigInt(a), BigInt(b)) => a.cmp(b), (Arr(a), Arr(b)) => { - if let (Some(ai), Some(bi)) = (a.iter_cheap(), b.iter_cheap()) { - for (a, b) in ai.zip(bi) { - let ord = evaluate_compare_op(&a, &b, op)?; - if !ord.is_eq() { - return Ok(ord); - } - } - } else { - let ai = a.iter(); - let bi = b.iter(); + let ai = a.iter(); + let bi = b.iter(); - for (a, b) in ai.zip(bi) { - let ord = evaluate_compare_op(&a?, &b?, op)?; - if !ord.is_eq() { - return Ok(ord); - } + for (a, b) in ai.zip(bi) { + let ord = evaluate_compare_op(&a?, &b?, op)?; + if !ord.is_eq() { + return Ok(ord); } } a.len().cmp(&b.len())