diff --git a/src/convert/slices.rs b/src/convert/slices.rs index bf41a33d..ba0e3cfe 100644 --- a/src/convert/slices.rs +++ b/src/convert/slices.rs @@ -128,20 +128,15 @@ vectors! { cfg_if! { if #[cfg(feature = "enable-interning")] { #[inline] - fn get_cached_str(x: &str) -> WasmSlice { - if let Some(x) = crate::cache::intern::get_str(x) { - // This uses 0 for the ptr as an indication that it is a JsValue and not a str - WasmSlice { ptr: 0, len: x.into_abi() } - - } else { - x.into_bytes().into_abi() - } + fn get_cached_str(x: &str) -> Option { + // This uses 0 for the ptr as an indication that it is a JsValue and not a str + crate::cache::intern::get_str(x).map(|x| WasmSlice { ptr: 0, len: x.into_abi() }) } } else { #[inline] - fn get_cached_str(x: &str) -> WasmSlice { - x.into_bytes().into_abi() + fn get_cached_str(_x: &str) -> Option { + None } } } @@ -177,7 +172,7 @@ if_std! { #[inline] fn into_abi(self) -> Self::Abi { - get_cached_str(&self) + get_cached_str(&self).unwrap_or_else(|| self.into_bytes().into_abi()) } } @@ -205,7 +200,7 @@ impl<'a> IntoWasmAbi for &'a str { #[inline] fn into_abi(self) -> Self::Abi { - get_cached_str(self) + get_cached_str(self).unwrap_or_else(|| self.as_bytes().into_abi()) } }