Skip to content

Commit 61f0f80

Browse files
committed
Avoid keeping the preinitialized home path in the image heap
* Also reduces the amount of code to run during patchContext().
1 parent 80fca05 commit 61f0f80

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main/ruby/truffleruby/post-boot/post-boot.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@
7171
if old_home
7272
# We need to fix all paths which capture the image build-time home to point
7373
# to the runtime home.
74+
75+
paths_starting_with_home = []
76+
[$LOAD_PATH, $LOADED_FEATURES].each do |array|
77+
array.each do |path|
78+
if path.start_with?(old_home)
79+
paths_starting_with_home << path[old_home.size..-1]
80+
end
81+
end
82+
end
83+
old_home = nil
84+
7485
Truffle::Boot.delay do
7586
new_home = Truffle::Boot.ruby_home
76-
[$LOAD_PATH, $LOADED_FEATURES].each do |array|
77-
array.each do |path|
78-
if path.start_with?(old_home)
79-
path.replace(new_home + path[old_home.size..-1])
80-
end
81-
end
87+
paths_starting_with_home.each do |path|
88+
path.replace(new_home + path)
8289
end
8390
end
8491
end

0 commit comments

Comments
 (0)