Skip to content

Commit

Permalink
Do fewer intermediary allocations when calculating test methods
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 13, 2023
1 parent 7e406af commit 4d0879d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/shoulda/context/context.rb
Original file line number Diff line number Diff line change
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 4d0879d

Please sign in to comment.