Skip to content

Commit fd88626

Browse files
committed
Fixing compile errors
1 parent 2ee4c54 commit fd88626

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/convert/slices.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,15 @@ vectors! {
128128
cfg_if! {
129129
if #[cfg(feature = "enable-interning")] {
130130
#[inline]
131-
fn get_cached_str(x: &str) -> WasmSlice {
132-
if let Some(x) = crate::cache::intern::get_str(x) {
133-
// This uses 0 for the ptr as an indication that it is a JsValue and not a str
134-
WasmSlice { ptr: 0, len: x.into_abi() }
135-
136-
} else {
137-
x.into_bytes().into_abi()
138-
}
131+
fn get_cached_str(x: &str) -> Option<WasmSlice> {
132+
// This uses 0 for the ptr as an indication that it is a JsValue and not a str
133+
crate::cache::intern::get_str(x).map(|x| WasmSlice { ptr: 0, len: x.into_abi() })
139134
}
140135

141136
} else {
142137
#[inline]
143-
fn get_cached_str(x: &str) -> WasmSlice {
144-
x.into_bytes().into_abi()
138+
fn get_cached_str(_x: &str) -> Option<WasmSlice> {
139+
None
145140
}
146141
}
147142
}
@@ -177,7 +172,7 @@ if_std! {
177172

178173
#[inline]
179174
fn into_abi(self) -> Self::Abi {
180-
get_cached_str(&self)
175+
get_cached_str(&self).unwrap_or_else(|| self.into_bytes().into_abi())
181176
}
182177
}
183178

@@ -205,7 +200,7 @@ impl<'a> IntoWasmAbi for &'a str {
205200

206201
#[inline]
207202
fn into_abi(self) -> Self::Abi {
208-
get_cached_str(self)
203+
get_cached_str(self).unwrap_or_else(|| self.as_bytes().into_abi())
209204
}
210205
}
211206

0 commit comments

Comments
 (0)