Skip to content

Commit

Permalink
Perf: speed up 2 methods in railties.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
miloops authored and spastorino committed Sep 22, 2010
1 parent dc2f26c commit 8cfc601
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion railties/lib/rails/code_statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def to_s

private
def calculate_statistics
@pairs.inject({}) { |stats, pair| stats[pair.first] = calculate_directory_statistics(pair.last); stats }
Hash[@pais.map { |pair| [pair.first, calculate_directory_statistics(pair.last)] }]

This comment has been minimized.

Copy link
@nono

nono Sep 23, 2010

Contributor

@pairs has become @pais (without the r). Typo?

This comment has been minimized.

Copy link
@josevalim

josevalim Sep 23, 2010

Contributor

Yes! Patch please? If you can include a failing test (look here http://github.com/rails/rails/blob/master/railties/test/application/rake_test.rb) you win extra internet hugs. :)

This comment has been minimized.

Copy link
@miloops

miloops Sep 24, 2010

Author Contributor

Hey,

Sorry for the typo, changed it and ran tests, everything was passing but only because it wasn't tested.

Fixed and added sanity test here: http://github.com/rails/rails/commit/63039b9c3356f73421b3742134959014d81973b0

end

def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
Expand Down
5 changes: 1 addition & 4 deletions railties/lib/rails/generators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ def self.find_by_namespace(name, base=nil, context=nil) #:nodoc:

lookup(lookups)

namespaces = subclasses.inject({}) do |hash, klass|
hash[klass.namespace] = klass
hash
end
namespaces = Hash[subclasses.map { |klass| [klass.namespace, klass] }]

lookups.each do |namespace|
klass = namespaces[namespace]
Expand Down

0 comments on commit 8cfc601

Please sign in to comment.