[前][次][番号順一覧][スレッド一覧]

ruby-changes:69899

From: NAKAMURA <ko1@a...>
Date: Wed, 24 Nov 2021 19:54:04 +0900 (JST)
Subject: [ruby-changes:69899] f236548038 (ruby_2_7): merge revision(s) 345db8f2aa373a31c619c8f85bd372f0a20829c1: [Backport #10902]

https://git.ruby-lang.org/ruby.git/commit/?id=f236548038

From f236548038048118e766232034511e4877a59b49 Mon Sep 17 00:00:00 2001
From: NAKAMURA Usaku <usa@r...>
Date: Wed, 24 Nov 2021 19:27:06 +0900
Subject: merge revision(s) 345db8f2aa373a31c619c8f85bd372f0a20829c1: [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(-)
---
 load.c    | 7 ++++++-
 version.h | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/load.c b/load.c
index 408339e0513..419ceae84d6 100644
--- a/load.c
+++ b/load.c
@@ -28,6 +28,11 @@ static const char *const loadable_ext[] = { https://github.com/ruby/ruby/blob/trunk/load.c#L28
     0
 };
 
+static const char *const ruby_ext[] = {
+    ".rb",
+    0
+};
+
 enum expand_type {
     EXPAND_ALL,
     EXPAND_RELATIVE,
@@ -937,7 +942,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p) https://github.com/ruby/ruby/blob/trunk/load.c#L942
 	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)
diff --git a/version.h b/version.h
index dbc8f4bbf20..ffcb0a7230a 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 5
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 194
+#define RUBY_PATCHLEVEL 195
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 11
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]