lib/bootsnap/load_path_cache/cache.rb in bootsnap-1.12.0 vs lib/bootsnap/load_path_cache/cache.rb in bootsnap-1.13.0
- old
+ new
@@ -43,24 +43,23 @@
end
end.freeze
# Try to resolve this feature to an absolute path without traversing the
# loadpath.
- def find(feature, try_extensions: true)
+ def find(feature)
reinitialize if (@has_relative_paths && dir_changed?) || stale?
feature = feature.to_s.freeze
return feature if Bootsnap.absolute_path?(feature)
if feature.start_with?("./", "../")
- return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze
+ return expand_path(feature)
end
@mutex.synchronize do
- x = search_index(feature, try_extensions: try_extensions)
+ x = search_index(feature)
return x if x
- return unless try_extensions
# Ruby has some built-in features that require lies about.
# For example, 'enumerator' is built in. If you require it, ruby
# returns false as if it were already loaded; however, there is no
# file to find on disk. We've pre-built a list of these, and we
@@ -113,11 +112,11 @@
end
def reinitialize(path_obj = @path_obj)
@mutex.synchronize do
@path_obj = path_obj
- ChangeObserver.register(self, @path_obj)
+ ChangeObserver.register(@path_obj, self)
@index = {}
@dirs = {}
@generated_at = now
push_paths_locked(*@path_obj)
end
@@ -181,43 +180,35 @@
def now
Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i
end
if DLEXT2
- def search_index(feature, try_extensions: true)
- if try_extensions
- try_index(feature + DOT_RB) ||
- try_index(feature + DLEXT) ||
- try_index(feature + DLEXT2) ||
- try_index(feature)
- else
+ def search_index(feature)
+ try_index(feature + DOT_RB) ||
+ try_index(feature + DLEXT) ||
+ try_index(feature + DLEXT2) ||
try_index(feature)
- end
end
def maybe_append_extension(feature)
try_ext(feature + DOT_RB) ||
try_ext(feature + DLEXT) ||
try_ext(feature + DLEXT2) ||
feature
end
else
- def search_index(feature, try_extensions: true)
- if try_extensions
- try_index(feature + DOT_RB) || try_index(feature + DLEXT) || try_index(feature)
- else
- try_index(feature)
- end
+ def search_index(feature)
+ try_index(feature + DOT_RB) || try_index(feature + DLEXT) || try_index(feature)
end
def maybe_append_extension(feature)
try_ext(feature + DOT_RB) || try_ext(feature + DLEXT) || feature
end
end
s = rand.to_s.force_encoding(Encoding::US_ASCII).freeze
if s.respond_to?(:-@)
- if (-s).equal?(s) && (-s.dup).equal?(s) || RUBY_VERSION >= "2.7"
+ if ((-s).equal?(s) && (-s.dup).equal?(s)) || RUBY_VERSION >= "2.7"
def try_index(feature)
if (path = @index[feature])
-File.join(path, feature).freeze
end
end