Skip to content

Commit

Permalink
Do fewer intermediary allocations when calculating test methods (#89)
Browse files Browse the repository at this point in the history
Showed up as the number one hotspot when profile the rubygems.org `rails test` startup time
  • Loading branch information
segiddins committed Sep 21, 2023
1 parent 7e406af commit 9c4a523
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/shoulda/context/context.rb
Expand Up @@ -100,7 +100,7 @@ def test_unit_class

def test_methods
@test_methods ||= Hash.new { |h,k|
h[k] = Hash[k.instance_methods.map { |n| [n, true] }]
h[k] = k.instance_methods.each_with_object({}) { |n, a| a[n] = true }
}
end

Expand Down Expand Up @@ -213,4 +213,3 @@ def method_missing(method, *args, &blk)
class DuplicateTestError < RuntimeError; end
end
end

0 comments on commit 9c4a523

Please sign in to comment.