Skip to content

Commit

Permalink
Merge pull request #125 from Shopify/save-some-path-duplications
Browse files Browse the repository at this point in the history
Freeze absolute paths for reduce allocations on file operations
  • Loading branch information
fxn authored Jun 28, 2020
2 parents 7084c7e + 0a68f87 commit c5b6582
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zeitwerk/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def set_autoload(parent, cname, abspath)
# $LOADED_FEATURES stores real paths since Ruby 2.4.4. We set and save the
# real path to be able to delete it from $LOADED_FEATURES on unload, and to
# be able to do a lookup later in Kernel#require for manual require calls.
realpath = File.realpath(abspath)
realpath = File.realpath(abspath).freeze
parent.autoload(cname, realpath)
if logger
if ruby?(realpath)
Expand Down Expand Up @@ -719,7 +719,7 @@ def cpath(parent, cname)
def ls(dir)
Dir.foreach(dir) do |basename|
next if basename.start_with?(".")
abspath = File.join(dir, basename)
abspath = File.join(dir, basename).freeze
yield basename, abspath unless ignored_paths.member?(abspath)
end
end
Expand Down

0 comments on commit c5b6582

Please sign in to comment.