Skip to content

Commit

Permalink
stop using send so that method privacy is respected and we get a small
Browse files Browse the repository at this point in the history
perf increase
  • Loading branch information
tenderlove committed Oct 22, 2013
1 parent 5ad34a8 commit 2dc8894
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions railties/lib/rails/paths.rb
Expand Up @@ -81,29 +81,29 @@ def all_paths
end

def autoload_once
filter_by(:autoload_once?)
filter_by { |p| p.autoload_once? }

This comment has been minimized.

Copy link
@egilburg

egilburg Oct 22, 2013

Contributor

You can just use filter_by &:autoload_once?

end

def eager_load
filter_by(:eager_load?)
filter_by { |p| p.eager_load? }
end

def autoload_paths
filter_by(:autoload?)
filter_by { |p| p.autoload? }
end

def load_paths
filter_by(:load_path?)
filter_by { |p| p.load_path? }
end

protected

def filter_by(constraint)
def filter_by
all = []
all_paths.each do |path|
if path.send(constraint)
if yield(path)
paths = path.existent
paths -= path.children.map { |p| p.send(constraint) ? [] : p.existent }.flatten
paths -= path.children.map { |p| yield(p) ? [] : p.existent }.flatten
all.concat(paths)
end
end
Expand Down

0 comments on commit 2dc8894

Please sign in to comment.