@@ -163,12 +163,6 @@ get_loaded_features_realpaths(rb_vm_t *vm)
163
163
return vm -> loaded_features_realpaths ;
164
164
}
165
165
166
- static VALUE
167
- get_loaded_features_realpath_map (rb_vm_t * vm )
168
- {
169
- return vm -> loaded_features_realpath_map ;
170
- }
171
-
172
166
static VALUE
173
167
get_LOADED_FEATURES (ID _x , VALUE * _y )
174
168
{
@@ -367,10 +361,7 @@ get_loaded_features_index(rb_vm_t *vm)
367
361
st_foreach (vm -> loaded_features_index , loaded_features_index_clear_i , 0 );
368
362
369
363
VALUE realpaths = vm -> loaded_features_realpaths ;
370
- VALUE realpath_map = vm -> loaded_features_realpath_map ;
371
- VALUE previous_realpath_map = rb_hash_dup (realpath_map );
372
364
rb_hash_clear (realpaths );
373
- rb_hash_clear (realpath_map );
374
365
features = vm -> loaded_features ;
375
366
for (i = 0 ; i < RARRAY_LEN (features ); i ++ ) {
376
367
VALUE entry , as_str ;
@@ -387,14 +378,9 @@ get_loaded_features_index(rb_vm_t *vm)
387
378
long j = RARRAY_LEN (features );
388
379
for (i = 0 ; i < j ; i ++ ) {
389
380
VALUE as_str = rb_ary_entry (features , i );
390
- VALUE realpath = rb_hash_aref (previous_realpath_map , as_str );
391
- if (NIL_P (realpath )) {
392
- realpath = rb_check_realpath (Qnil , as_str , NULL );
393
- if (NIL_P (realpath )) realpath = as_str ;
394
- realpath = rb_fstring (realpath );
395
- }
396
- rb_hash_aset (realpaths , realpath , Qtrue );
397
- rb_hash_aset (realpath_map , as_str , realpath );
381
+ VALUE realpath = rb_check_realpath (Qnil , as_str , NULL );
382
+ if (NIL_P (realpath )) realpath = as_str ;
383
+ rb_hash_aset (realpaths , rb_fstring (realpath ), Qtrue );
398
384
}
399
385
}
400
386
return vm -> loaded_features_index ;
@@ -689,19 +675,6 @@ rb_provide(const char *feature)
689
675
690
676
NORETURN (static void load_failed (VALUE ));
691
677
692
- static inline VALUE
693
- realpath_internal_cached (VALUE hash , VALUE path )
694
- {
695
- VALUE ret = rb_hash_aref (hash , path );
696
- if (RTEST (ret )) {
697
- return ret ;
698
- }
699
-
700
- VALUE realpath = rb_realpath_internal (Qnil , path , 1 );
701
- rb_hash_aset (hash , rb_fstring (path ), rb_fstring (realpath ));
702
- return realpath ;
703
- }
704
-
705
678
static inline void
706
679
load_iseq_eval (rb_execution_context_t * ec , VALUE fname )
707
680
{
@@ -714,12 +687,8 @@ load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
714
687
VALUE parser = rb_parser_new ();
715
688
rb_parser_set_context (parser , NULL , FALSE);
716
689
ast = (rb_ast_t * )rb_parser_load_file (parser , fname );
717
-
718
- rb_thread_t * th = rb_ec_thread_ptr (ec );
719
- VALUE realpath_map = get_loaded_features_realpath_map (th -> vm );
720
-
721
690
iseq = rb_iseq_new_top (& ast -> body , rb_fstring_lit ("<top (required)>" ),
722
- fname , realpath_internal_cached ( realpath_map , fname ), NULL );
691
+ fname , rb_realpath_internal ( Qnil , fname , 1 ), NULL );
723
692
rb_ast_dispose (ast );
724
693
rb_vm_pop_frame (ec );
725
694
RB_GC_GUARD (v );
@@ -1192,7 +1161,6 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
1192
1161
volatile VALUE saved_path ;
1193
1162
volatile VALUE realpath = 0 ;
1194
1163
VALUE realpaths = get_loaded_features_realpaths (th -> vm );
1195
- VALUE realpath_map = get_loaded_features_realpath_map (th -> vm );
1196
1164
volatile bool reset_ext_config = false;
1197
1165
struct rb_ext_config prev_ext_config ;
1198
1166
@@ -1226,7 +1194,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
1226
1194
}
1227
1195
#endif
1228
1196
else if (RTEST (rb_hash_aref (realpaths ,
1229
- realpath = realpath_internal_cached ( realpath_map , path )))) {
1197
+ realpath = rb_realpath_internal ( Qnil , path , 1 )))) {
1230
1198
result = 0 ;
1231
1199
}
1232
1200
else {
@@ -1284,8 +1252,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
1284
1252
rb_provide_feature (th2 -> vm , path );
1285
1253
VALUE real = realpath ;
1286
1254
if (real ) {
1287
- real = rb_fstring (real );
1288
- rb_hash_aset (realpaths , real , Qtrue );
1255
+ rb_hash_aset (realpaths , rb_fstring (real ), Qtrue );
1289
1256
}
1290
1257
}
1291
1258
ec -> errinfo = saved .errinfo ;
@@ -1506,8 +1473,6 @@ Init_load(void)
1506
1473
vm -> loaded_features_index = st_init_numtable ();
1507
1474
vm -> loaded_features_realpaths = rb_hash_new ();
1508
1475
rb_obj_hide (vm -> loaded_features_realpaths );
1509
- vm -> loaded_features_realpath_map = rb_hash_new ();
1510
- rb_obj_hide (vm -> loaded_features_realpath_map );
1511
1476
1512
1477
rb_define_global_function ("load" , rb_f_load , -1 );
1513
1478
rb_define_global_function ("require" , rb_f_require , 1 );
0 commit comments