1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-04-17 02:42:13 +00:00

Fixing compile errors

This commit is contained in:
Pauan 2019-07-16 22:48:41 +02:00
parent 2ee4c54f00
commit fd88626e38

@ -128,20 +128,15 @@ vectors! {
cfg_if! { cfg_if! {
if #[cfg(feature = "enable-interning")] { if #[cfg(feature = "enable-interning")] {
#[inline] #[inline]
fn get_cached_str(x: &str) -> WasmSlice { fn get_cached_str(x: &str) -> Option<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 // 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() } crate::cache::intern::get_str(x).map(|x| WasmSlice { ptr: 0, len: x.into_abi() })
} else {
x.into_bytes().into_abi()
}
} }
} else { } else {
#[inline] #[inline]
fn get_cached_str(x: &str) -> WasmSlice { fn get_cached_str(_x: &str) -> Option<WasmSlice> {
x.into_bytes().into_abi() None
} }
} }
} }
@ -177,7 +172,7 @@ if_std! {
#[inline] #[inline]
fn into_abi(self) -> Self::Abi { 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] #[inline]
fn into_abi(self) -> Self::Abi { fn into_abi(self) -> Self::Abi {
get_cached_str(self) get_cached_str(self).unwrap_or_else(|| self.as_bytes().into_abi())
} }
} }