Skip to content

Commit 677a93d

Browse files
committed
Simplify to a single instance variable for #same_working_directory_for_load_path?
(cherry picked from commit c1d8c1a)
1 parent 4e4c31f commit 677a93d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/ruby/truffleruby/core/truffle/feature_loader.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module FeatureLoader
2121
@expanded_load_path = []
2222
# A snapshot of $LOAD_PATH, to check if the @expanded_load_path cache is up to date.
2323
@load_path_copy = []
24-
@relative_path_in_load_path = false
24+
# nil if there is no relative path in $LOAD_PATH, a copy of the cwd to check if the cwd changed otherwise.
2525
@working_directory_copy = nil
2626

2727
def self.clear_cache
@@ -284,10 +284,9 @@ def self.get_expanded_load_path
284284
unless Primitive.array_storage_equal?(@load_path_copy, $LOAD_PATH) && same_working_directory_for_load_path?
285285
@expanded_load_path = $LOAD_PATH.map do |path|
286286
path = Truffle::Type.coerce_to_path(path)
287-
unless @relative_path_in_load_path
287+
unless @working_directory_copy
288288
unless File.absolute_path?(path)
289289
@working_directory_copy = Primitive.working_directory
290-
@relative_path_in_load_path = true
291290
end
292291
end
293292
Primitive.canonicalize_path(path)
@@ -298,8 +297,8 @@ def self.get_expanded_load_path
298297
end
299298

300299
def self.same_working_directory_for_load_path?
301-
if @relative_path_in_load_path
302-
if Primitive.working_directory == @working_directory_copy
300+
if working_directory_copy = @working_directory_copy
301+
if Primitive.working_directory == working_directory_copy
303302
true
304303
else
305304
@working_directory_copy = Primitive.working_directory

0 commit comments

Comments
 (0)