@@ -85,13 +85,13 @@ impl CacheRegion {
85
85
pub fn remove ( & mut self , key : & str ) -> Option < CacheEntry > {
86
86
self . lru_cache . pop ( key)
87
87
}
88
- pub fn put ( & mut self , key : & str , val : JsValueFacade ) {
88
+ pub fn put ( & mut self , key : String , val : JsValueFacade ) {
89
89
let ce = CacheEntry {
90
90
val,
91
91
created : Instant :: now ( ) ,
92
92
last_used : Instant :: now ( ) ,
93
93
} ;
94
- self . lru_cache . put ( key. to_string ( ) , ce) ;
94
+ self . lru_cache . put ( key, ce) ;
95
95
}
96
96
fn invalidate_stale ( & mut self ) {
97
97
let min_last_used = Instant :: now ( ) . sub ( self . max_idle ) ;
@@ -238,7 +238,7 @@ impl NativeModuleLoader for CacheModuleLoader {
238
238
239
239
fn cache_add (
240
240
realm : & QuickJsRealmAdapter ,
241
- key : & str ,
241
+ key : String ,
242
242
value : & QuickJsValueAdapter ,
243
243
region : & mut CacheRegion ,
244
244
) -> Result < ( ) , JsError > {
@@ -293,8 +293,9 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
293
293
"cache_add_func" ,
294
294
move |realm, _this, args| {
295
295
// cache args 0
296
+ let key_clone = key. clone ( ) ;
296
297
with_cache_region ( & instance_id, |cache_region2| {
297
- cache_add ( realm, & key , & args[ 0 ] , cache_region2)
298
+ cache_add ( realm, key_clone , & args[ 0 ] , cache_region2)
298
299
} ) ?;
299
300
300
301
realm. create_null ( )
@@ -303,7 +304,7 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
303
304
) ?;
304
305
realm. add_promise_reactions ( & init_result, Some ( then) , None , None ) ?;
305
306
} else {
306
- cache_add ( realm, & key, & init_result, cache_region) ?;
307
+ cache_add ( realm, key, & init_result, cache_region) ?;
307
308
}
308
309
Ok ( init_result)
309
310
}
@@ -322,7 +323,7 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
322
323
) ) ;
323
324
}
324
325
325
- let key = args[ 0 ] . to_str ( ) ?;
326
+ let key = args[ 0 ] . to_string ( ) ?;
326
327
let val = realm. to_js_value_facade ( & args[ 1 ] ) ?;
327
328
328
329
with_cache_region ( instance_id, move |cache_region| {
0 commit comments