git.delta.rocks / jrsonnet / refs/commits / 364fdf96177a

difftreelog

perf inline trivial IntoUntyped

zpzozrxmYaroslav Bolyukin2026-04-25parent: #4944c9e.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
134 const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);134 const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);
135}135}
136136
137#[inline]
137fn try_cast_thunk_val<T: 'static>(typed: Thunk<T>) -> Result<Thunk<Val>, Thunk<T>> {138fn try_cast_thunk_val<T: 'static>(typed: Thunk<T>) -> Result<Thunk<Val>, Thunk<T>> {
138 if TypeId::of::<T>() == TypeId::of::<Val>() {139 if TypeId::of::<T>() == TypeId::of::<Val>() {
139 // SAFETY: We know that it is exactly the same type, and we discard the original after that140 // SAFETY: We know that it is exactly the same type, and we discard the original after that
148where149where
149 T: IntoUntyped + Trace + Clone,150 T: IntoUntyped + Trace + Clone,
150{151{
152 #[inline]
151 fn into_untyped(typed: Self) -> Result<Val> {153 fn into_untyped(typed: Self) -> Result<Val> {
152 T::into_untyped(typed.evaluate()?)154 T::into_untyped(typed.evaluate()?)
153 }155 }
185 }187 }
186}188}
187189
190#[inline]
188fn try_cast_thunk_t<T: 'static>(typed: Thunk<Val>) -> Result<Thunk<T>, Thunk<Val>> {191fn try_cast_thunk_t<T: 'static>(typed: Thunk<Val>) -> Result<Thunk<T>, Thunk<Val>> {
189 if TypeId::of::<T>() == TypeId::of::<Val>() {192 if TypeId::of::<T>() == TypeId::of::<Val>() {
190 // SAFETY: We know that it is exactly the same type, and we discard the original after that193 // SAFETY: We know that it is exactly the same type, and we discard the original after that
581 const TYPE: &'static ComplexValType = &ComplexValType::Any;584 const TYPE: &'static ComplexValType = &ComplexValType::Any;
582}585}
583impl IntoUntyped for &Val {586impl IntoUntyped for &Val {
587 #[inline]
584 fn into_untyped(typed: Self) -> Result<Val> {588 fn into_untyped(typed: Self) -> Result<Val> {
585 Ok(typed.clone())589 Ok(typed.clone())
586 }590 }
587}591}
588impl IntoUntyped for Val {592impl IntoUntyped for Val {
593 #[inline]
589 fn into_untyped(typed: Self) -> Result<Val> {594 fn into_untyped(typed: Self) -> Result<Val> {
590 Ok(typed)595 Ok(typed)
591 }596 }