mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
Fixing unsafe_get_str function
This commit is contained in:
parent
10ab4cbc18
commit
f8da1e672f
5
src/cache/intern.rs
vendored
5
src/cache/intern.rs
vendored
@ -9,7 +9,6 @@ cfg_if! {
|
|||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::JsValue;
|
use crate::JsValue;
|
||||||
use crate::convert::IntoWasmAbi;
|
|
||||||
|
|
||||||
struct Cache {
|
struct Cache {
|
||||||
entries: RefCell<HashMap<String, JsValue>>,
|
entries: RefCell<HashMap<String, JsValue>>,
|
||||||
@ -23,11 +22,11 @@ cfg_if! {
|
|||||||
|
|
||||||
/// This returns the raw index of the cached JsValue, so you must take care
|
/// This returns the raw index of the cached JsValue, so you must take care
|
||||||
/// so that you don't use it after it is freed.
|
/// so that you don't use it after it is freed.
|
||||||
pub(crate) fn unsafe_get_str(s: &str) -> Option<<JsValue as IntoWasmAbi>::Abi> {
|
pub(crate) fn unsafe_get_str(s: &str) -> Option<u32> {
|
||||||
CACHE.with(|cache| {
|
CACHE.with(|cache| {
|
||||||
let cache = cache.entries.borrow();
|
let cache = cache.entries.borrow();
|
||||||
|
|
||||||
cache.get(s).map(|x| x.into_abi())
|
cache.get(s).map(|x| x.idx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user