Skip to content

Commit

Permalink
style and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Jun 28, 2020
1 parent c5b6582 commit 88e1a6b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/zeitwerk/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ 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.
#
# We freeze realpath because that saves allocations in Module#autoload.
# See #125.
realpath = File.realpath(abspath).freeze
parent.autoload(cname, realpath)
if logger
Expand Down Expand Up @@ -719,8 +722,13 @@ def cpath(parent, cname)
def ls(dir)
Dir.foreach(dir) do |basename|
next if basename.start_with?(".")
abspath = File.join(dir, basename).freeze
yield basename, abspath unless ignored_paths.member?(abspath)

abspath = File.join(dir, basename)
next if ignored_paths.member?(abspath)

# We freeze abspath because that saves allocations when passed later to
# File methods. See #125.
yield basename, abspath.freeze
end
end

Expand Down

0 comments on commit 88e1a6b

Please sign in to comment.