@@ -16,7 +16,6 @@ module URI
1616 REGEXP = RFC2396_REGEXP
1717 Parser = RFC2396_Parser
1818 RFC3986_PARSER = RFC3986_Parser . new
19- Ractor . make_shareable ( RFC3986_PARSER ) if defined? ( Ractor )
2019
2120 # URI::Parser.new
2221 DEFAULT_PARSER = Parser . new
@@ -28,7 +27,6 @@ module URI
2827 DEFAULT_PARSER . regexp . each_pair do |sym , str |
2928 const_set ( sym , str )
3029 end
31- Ractor . make_shareable ( DEFAULT_PARSER ) if defined? ( Ractor )
3230
3331 module Util # :nodoc:
3432 def make_components_hash ( klass , array_hash )
@@ -64,38 +62,22 @@ def make_components_hash(klass, array_hash)
6462
6563 include REGEXP
6664
67- SCHEME_LIST_MUTEX = Mutex . new
68- private_constant :SCHEME_LIST_MUTEX
69-
65+ @@schemes = { }
7066 # Returns a Hash of the defined schemes.
71- # The list is lazily calculated.
7267 def self . scheme_list
73- return const_get ( :SCHEMES ) if defined? ( SCHEMES )
74-
75- SCHEME_LIST_MUTEX . synchronize do
76- const_set ( :SCHEMES , ObjectSpace .
77- each_object ( Class ) .
78- select { |klass | klass < URI ::Generic } .
79- each_with_object ( { } ) { |klass , acc | acc [ klass . name . split ( '::' ) . last . upcase ] = klass } .
80- freeze )
81- end
82- end
83-
84- # Re-calculate scheme list
85- def self . refresh_scheme_list
86- SCHEME_LIST_MUTEX . synchronize do
87- remove_const ( :SCHEMES ) if defined? ( SCHEMES )
88- end
89-
90- scheme_list
68+ @@schemes
9169 end
9270
9371 #
9472 # Construct a URI instance, using the scheme to detect the appropriate class
9573 # from +URI.scheme_list+.
9674 #
9775 def self . for ( scheme , *arguments , default : Generic )
98- uri_class = scheme_list [ scheme . to_s . upcase ] || default
76+ if scheme
77+ uri_class = @@schemes [ scheme . upcase ] || default
78+ else
79+ uri_class = default
80+ end
9981
10082 return uri_class . new ( scheme , *arguments )
10183 end
0 commit comments