@@ -85,13 +85,13 @@ impl CacheRegion {
8585 pub fn remove ( & mut self , key : & str ) -> Option < CacheEntry > {
8686 self . lru_cache . pop ( key)
8787 }
88- pub fn put ( & mut self , key : & str , val : JsValueFacade ) {
88+ pub fn put ( & mut self , key : String , val : JsValueFacade ) {
8989 let ce = CacheEntry {
9090 val,
9191 created : Instant :: now ( ) ,
9292 last_used : Instant :: now ( ) ,
9393 } ;
94- self . lru_cache . put ( key. to_string ( ) , ce) ;
94+ self . lru_cache . put ( key, ce) ;
9595 }
9696 fn invalidate_stale ( & mut self ) {
9797 let min_last_used = Instant :: now ( ) . sub ( self . max_idle ) ;
@@ -238,7 +238,7 @@ impl NativeModuleLoader for CacheModuleLoader {
238238
239239fn cache_add (
240240 realm : & QuickJsRealmAdapter ,
241- key : & str ,
241+ key : String ,
242242 value : & QuickJsValueAdapter ,
243243 region : & mut CacheRegion ,
244244) -> Result < ( ) , JsError > {
@@ -293,8 +293,9 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
293293 "cache_add_func" ,
294294 move |realm, _this, args| {
295295 // cache args 0
296+ let key_clone = key. clone ( ) ;
296297 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)
298299 } ) ?;
299300
300301 realm. create_null ( )
@@ -303,7 +304,7 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
303304 ) ?;
304305 realm. add_promise_reactions ( & init_result, Some ( then) , None , None ) ?;
305306 } else {
306- cache_add ( realm, & key, & init_result, cache_region) ?;
307+ cache_add ( realm, key, & init_result, cache_region) ?;
307308 }
308309 Ok ( init_result)
309310 }
@@ -322,7 +323,7 @@ fn init_region_proxy(realm: &QuickJsRealmAdapter) -> Result<(), JsError> {
322323 ) ) ;
323324 }
324325
325- let key = args[ 0 ] . to_str ( ) ?;
326+ let key = args[ 0 ] . to_string ( ) ?;
326327 let val = realm. to_js_value_facade ( & args[ 1 ] ) ?;
327328
328329 with_cache_region ( instance_id, move |cache_region| {
0 commit comments