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

ruby-changes:58900

From: aycabta <ko1@a...>
Date: Mon, 25 Nov 2019 07:29:07 +0900 (JST)
Subject: [ruby-changes:58900] fd956c72ea (master): Cache loaded module to suppress method redefined warnings

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

From fd956c72eaeb07d26d61310a9e4b55b500237c02 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Mon, 25 Nov 2019 07:27:15 +0900
Subject: Cache loaded module to suppress method redefined warnings


diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index b713f50..ba833ec 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -21,6 +21,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/locale.rb#L21
     LOCALE_DIR = "/lc/"
 
     @@legacy_encoding_alias_map = {}.freeze
+    @@loaded = []
 
     def initialize(locale = nil)
       @lang = @territory = @encoding_name = @modifier = nil
@@ -107,7 +108,10 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/locale.rb#L108
     def load(file, priv=nil)
       found = find(file)
       if found
-        return real_load(found, priv)
+        unless @@loaded.include?(found)
+          @@loaded << found # cache
+          return real_load(found, priv)
+        end
       else
         raise LoadError, "No such file to load -- #{file}"
       end
-- 
cgit v0.10.2


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

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