aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-25 12:56:15 -0400
committerGitHub <noreply@github.com>2019-07-25 12:56:15 -0400
commit53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91 (patch)
tree8b9b0c6faa1a39ea743c75b80b43730c863a0f1e
parent1d83ab936672790ea3abd407df8c16d696aaef70 (diff)
parent62a1d7e9c183c418890d36c3f0068eb815a506d0 (diff)
downloadrails-53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91.tar.gz
rails-53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91.tar.bz2
rails-53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91.zip
Merge pull request #36762 from Shopify/descendants-tracker-cleanup
Optimize DescendantsArray insertions
-rw-r--r--activesupport/lib/active_support/descendants_tracker.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb
index 1dad4f923e..b14842bf67 100644
--- a/activesupport/lib/active_support/descendants_tracker.rb
+++ b/activesupport/lib/active_support/descendants_tracker.rb
@@ -77,15 +77,17 @@ module ActiveSupport
end
def <<(klass)
- cleanup!
@refs << WeakRef.new(klass)
end
def each
- @refs.each do |ref|
+ @refs.reject! do |ref|
yield ref.__getobj__
+ false
rescue WeakRef::RefError
+ true
end
+ self
end
def refs_size