|
1 | | -use std::sync::OnceLock; |
2 | | - |
3 | 1 | use type_::{FieldMap, TypedCallArg}; |
4 | 2 |
|
5 | 3 | use super::*; |
@@ -607,7 +605,7 @@ impl TypedExpr { |
607 | 605 | pub fn is_non_zero_compile_time_number(&self) -> bool { |
608 | 606 | match self { |
609 | 607 | Self::Int { int_value, .. } => int_value != &BigInt::ZERO, |
610 | | - Self::Float { value, .. } => is_non_zero_number(value), |
| 608 | + Self::Float { float_value, .. } => !float_value.value().is_zero(), |
611 | 609 | Self::String { .. } |
612 | 610 | | Self::Block { .. } |
613 | 611 | | Self::Pipeline { .. } |
@@ -636,7 +634,7 @@ impl TypedExpr { |
636 | 634 | pub fn is_zero_compile_time_number(&self) -> bool { |
637 | 635 | match self { |
638 | 636 | Self::Int { int_value, .. } => int_value == &BigInt::ZERO, |
639 | | - Self::Float { value, .. } => !is_non_zero_number(value), |
| 637 | + Self::Float { float_value, .. } => float_value.value().is_zero(), |
640 | 638 | Self::String { .. } |
641 | 639 | | Self::Block { .. } |
642 | 640 | | Self::Pipeline { .. } |
@@ -1655,15 +1653,6 @@ pub(crate) fn pairwise_all<A>(one: &[A], other: &[A], function: impl Fn((&A, &A) |
1655 | 1653 | one.len() == other.len() && one.iter().zip(other).all(function) |
1656 | 1654 | } |
1657 | 1655 |
|
1658 | | -fn is_non_zero_number(value: &EcoString) -> bool { |
1659 | | - use regex::Regex; |
1660 | | - static NON_ZERO: OnceLock<Regex> = OnceLock::new(); |
1661 | | - |
1662 | | - NON_ZERO |
1663 | | - .get_or_init(|| Regex::new(r"[1-9]").expect("NON_ZERO regex")) |
1664 | | - .is_match(value) |
1665 | | -} |
1666 | | - |
1667 | 1656 | impl<'a> From<&'a TypedExpr> for Located<'a> { |
1668 | 1657 | fn from(expression: &'a TypedExpr) -> Self { |
1669 | 1658 | Located::Expression { |
|
0 commit comments