Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze absolute paths for reduce allocations on file operations #125

Merged
merged 1 commit into from Jun 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/zeitwerk/loader.rb
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