Skip to content

Commit efd35db

Browse files
committed
Make rb_load_entrypoint accept two arguments directly
`rb_load_entrypoint` is used only by `rb_box_load`; it checks that the argument has two-elements (implicitly assuming it is an array), extracts its contents, and then simply discards the argument.
1 parent 9af2c55 commit efd35db

3 files changed

Lines changed: 5 additions & 18 deletions

File tree

box.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ rb_box_load(int argc, VALUE *argv, VALUE box)
860860

861861
rb_vm_frame_flag_set_box_require(GET_EC());
862862

863-
VALUE args = rb_ary_new_from_args(2, fname, wrap);
864-
return rb_load_entrypoint(args);
863+
return rb_load_entrypoint(fname, wrap);
865864
}
866865

867866
static VALUE

internal/load.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/* load.c */
1414
VALUE rb_get_expanded_load_path(void);
15-
VALUE rb_load_entrypoint(VALUE args);
15+
VALUE rb_load_entrypoint(VALUE fname, VALUE wrap);
1616
VALUE rb_require_relative_entrypoint(VALUE fname);
1717
int rb_require_internal(VALUE fname);
1818
NORETURN(void rb_load_fail(VALUE, const char*));

load.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,8 @@ rb_load_protect(VALUE fname, int wrap, int *pstate)
875875
if (state != TAG_NONE) *pstate = state;
876876
}
877877

878-
static VALUE
879-
load_entrypoint_internal(VALUE fname, VALUE wrap)
878+
VALUE
879+
rb_load_entrypoint(VALUE fname, VALUE wrap)
880880
{
881881
VALUE path, orig_fname;
882882

@@ -897,18 +897,6 @@ load_entrypoint_internal(VALUE fname, VALUE wrap)
897897
return Qtrue;
898898
}
899899

900-
VALUE
901-
rb_load_entrypoint(VALUE args)
902-
{
903-
VALUE fname, wrap;
904-
if (RARRAY_LEN(args) != 2) {
905-
rb_bug("invalid arguments: %ld", RARRAY_LEN(args));
906-
}
907-
fname = rb_ary_entry(args, 0);
908-
wrap = rb_ary_entry(args, 1);
909-
return load_entrypoint_internal(fname, wrap);
910-
}
911-
912900
/*
913901
* call-seq:
914902
* load(filename, wrap=false) -> true
@@ -944,7 +932,7 @@ rb_f_load(int argc, VALUE *argv, VALUE _)
944932
{
945933
VALUE fname, wrap;
946934
rb_scan_args(argc, argv, "11", &fname, &wrap);
947-
return load_entrypoint_internal(fname, wrap);
935+
return rb_load_entrypoint(fname, wrap);
948936
}
949937

950938
static char *

0 commit comments

Comments
 (0)