1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 345db8f2aa: [Backport #10902]

Avoid pointless attempts to open .so file if already required

	When attempting to require a file without an extension that has
	already been required or provided with an .so extension, only
	look for files with an .rb extension. There is no point in
	trying to find files with an .so extension, since we already
	know one has been loaded.

	Previously, attempting to require such a file scanned the load
	path twice, once for .rb and once for .so.  Now it only scans
	once for .rb.  The scan once for .rb cannot be avoided, since
	the .rb file would take precedence and should be loaded if it
	exists.

	Fixes [Bug #10902]
	---
	 load.c | 7 ++++++-
	 1 file changed, 6 insertions(+), 1 deletion(-)
This commit is contained in:
nagachika 2021-08-01 18:30:39 +09:00
parent 0dbb3c15db
commit 6f4ab641bb
2 changed files with 7 additions and 2 deletions

7
load.c
View file

@ -35,6 +35,11 @@ static const char *const loadable_ext[] = {
0
};
static const char *const ruby_ext[] = {
".rb",
0
};
enum expand_type {
EXPAND_ALL,
EXPAND_RELATIVE,
@ -964,7 +969,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
return 'r';
}
tmp = fname;
type = rb_find_file_ext(&tmp, loadable_ext);
type = rb_find_file_ext(&tmp, ft == 's' ? ruby_ext : loadable_ext);
switch (type) {
case 0:
if (ft)

View file

@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 118
#define RUBY_PATCHLEVEL 119
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 8