difftreelog
perf inline NumValue methods
in: master
3 files changed
crates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth--- 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)) => {
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth409 }409 }410 Some(Self(v))410 Some(Self(v))411 }411 }412 #[inline]412 pub const fn get(&self) -> f64 {413 pub const fn get(&self) -> f64 {413 self.0414 self.0414 }415 }420}421}421impl Eq for NumValue {}422impl Eq for NumValue {}422impl Ord for NumValue {423impl Ord for NumValue {424 #[inline]423 fn cmp(&self, other: &Self) -> Ordering {425 fn cmp(&self, other: &Self) -> Ordering {424 // Can't use `total_cmp`: its behavior for `-0` and `0`426 // Can't use `total_cmp`: its behavior for `-0` and `0`425 // is not following wanted.427 // is not following wanted.426 self.0.partial_cmp(&other.0).expect("NaNs are disallowed")428 unsafe { self.0.partial_cmp(&other.0).unwrap_unchecked() }427 }429 }428}430}429impl PartialOrd for NumValue {431impl PartialOrd for NumValue {432 #[inline]430 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {433 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {431 Some(self.cmp(other))434 Some(self.cmp(other))432 }435 }439impl Deref for NumValue {442impl Deref for NumValue {440 type Target = f64;443 type Target = f64;441444445 #[inline]442 fn deref(&self) -> &Self::Target {446 fn deref(&self) -> &Self::Target {443 &self.0447 &self.0444 }448 }445}449}446macro_rules! impl_num {450macro_rules! impl_num {447 ($($ty:ty),+) => {$(451 ($($ty:ty),+) => {$(448 impl From<$ty> for NumValue {452 impl From<$ty> for NumValue {453 #[inline]449 fn from(value: $ty) -> Self {454 fn from(value: $ty) -> Self {450 Self(value.into())455 Self(value.into())451 }456 }473 ($($ty:ty),+) => {$(478 ($($ty:ty),+) => {$(474 impl TryFrom<$ty> for NumValue {479 impl TryFrom<$ty> for NumValue {475 type Error = ConvertNumValueError;480 type Error = ConvertNumValueError;481 #[inline]476 fn try_from(value: $ty) -> Result<Self, ConvertNumValueError> {482 fn try_from(value: $ty) -> Result<Self, ConvertNumValueError> {477 use crate::typed::conversions::{MIN_SAFE_INTEGER, MAX_SAFE_INTEGER};483 use crate::typed::conversions::{MIN_SAFE_INTEGER, MAX_SAFE_INTEGER};478 let value = value as f64;484 let value = value as f64;492impl TryFrom<f64> for NumValue {498impl TryFrom<f64> for NumValue {493 type Error = ConvertNumValueError;499 type Error = ConvertNumValueError;494500501 #[inline]495 fn try_from(value: f64) -> Result<Self, Self::Error> {502 fn try_from(value: f64) -> Result<Self, Self::Error> {496 Self::new(value).ok_or(ConvertNumValueError::NonFinite)503 Self::new(value).ok_or(ConvertNumValueError::NonFinite)497 }504 }498}505}499impl TryFrom<f32> for NumValue {506impl TryFrom<f32> for NumValue {500 type Error = ConvertNumValueError;507 type Error = ConvertNumValueError;501508509 #[inline]502 fn try_from(value: f32) -> Result<Self, Self::Error> {510 fn try_from(value: f32) -> Result<Self, Self::Error> {503 Self::new(f64::from(value)).ok_or(ConvertNumValueError::NonFinite)511 Self::new(f64::from(value)).ok_or(ConvertNumValueError::NonFinite)504 }512 }nix/jrsonnet.nixdiffbeforeafterboth--- 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];