File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -128,20 +128,15 @@ vectors! {
128
128
cfg_if ! {
129
129
if #[ cfg( feature = "enable-interning" ) ] {
130
130
#[ 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( ) } )
139
134
}
140
135
141
136
} else {
142
137
#[ 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
145
140
}
146
141
}
147
142
}
@@ -177,7 +172,7 @@ if_std! {
177
172
178
173
#[ inline]
179
174
fn into_abi( self ) -> Self :: Abi {
180
- get_cached_str( & self )
175
+ get_cached_str( & self ) . unwrap_or_else ( || self . into_bytes ( ) . into_abi ( ) )
181
176
}
182
177
}
183
178
@@ -205,7 +200,7 @@ impl<'a> IntoWasmAbi for &'a str {
205
200
206
201
#[ inline]
207
202
fn into_abi ( self ) -> Self :: Abi {
208
- get_cached_str ( self )
203
+ get_cached_str ( self ) . unwrap_or_else ( || self . as_bytes ( ) . into_abi ( ) )
209
204
}
210
205
}
211
206
You can’t perform that action at this time.
0 commit comments