--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs +++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs @@ -94,7 +94,7 @@ use Val::*; Ok(match (a, b) { (Str(a), Str(b)) => a.cmp(b), - (Num(a), Num(b)) => a.partial_cmp(b).expect("jsonnet numbers are non NaN"), + (Num(a), Num(b)) => a.cmp(b), #[cfg(feature = "exp-bigint")] (BigInt(a), BigInt(b)) => a.cmp(b), (Arr(a), Arr(b)) => { --- a/crates/jrsonnet-evaluator/src/val.rs +++ b/crates/jrsonnet-evaluator/src/val.rs @@ -409,6 +409,7 @@ } Some(Self(v)) } + #[inline] pub const fn get(&self) -> f64 { self.0 } @@ -420,13 +421,15 @@ } impl Eq for NumValue {} impl Ord for NumValue { + #[inline] fn cmp(&self, other: &Self) -> Ordering { // Can't use `total_cmp`: its behavior for `-0` and `0` // is not following wanted. - self.0.partial_cmp(&other.0).expect("NaNs are disallowed") + unsafe { self.0.partial_cmp(&other.0).unwrap_unchecked() } } } impl PartialOrd for NumValue { + #[inline] fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } @@ -439,6 +442,7 @@ impl Deref for NumValue { type Target = f64; + #[inline] fn deref(&self) -> &Self::Target { &self.0 } @@ -446,6 +450,7 @@ macro_rules! impl_num { ($($ty:ty),+) => {$( impl From<$ty> for NumValue { + #[inline] fn from(value: $ty) -> Self { Self(value.into()) } @@ -473,6 +478,7 @@ ($($ty:ty),+) => {$( impl TryFrom<$ty> for NumValue { type Error = ConvertNumValueError; + #[inline] fn try_from(value: $ty) -> Result { use crate::typed::conversions::{MIN_SAFE_INTEGER, MAX_SAFE_INTEGER}; let value = value as f64; @@ -492,6 +498,7 @@ impl TryFrom for NumValue { type Error = ConvertNumValueError; + #[inline] fn try_from(value: f64) -> Result { Self::new(value).ok_or(ConvertNumValueError::NonFinite) } @@ -499,6 +506,7 @@ impl TryFrom for NumValue { type Error = ConvertNumValueError; + #[inline] fn try_from(value: f32) -> Result { Self::new(f64::from(value)).ok_or(ConvertNumValueError::NonFinite) } --- a/nix/jrsonnet.nix +++ b/nix/jrsonnet.nix @@ -17,7 +17,7 @@ pname = "jrsonnet"; version = "current${optionalString withNightlyFeatures "-nightly"}${optionalString withExperimentalFeatures "-experimental"}"; - cargoExtraArgs = "--locked --features=mimalloc,legacy-this-file${optionalString withNightlyFeatures ",nightly"}${optionalString withExperimentalFeatures ",experimental"}"; + cargoExtraArgs = "--locked --features=mimalloc${optionalString withNightlyFeatures ",nightly"}${optionalString withExperimentalFeatures ",experimental"}"; nativeBuildInputs = [makeWrapper];