From 62a1d7e9c183c418890d36c3f0068eb815a506d0 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 25 Jul 2019 11:37:39 -0400 Subject: [PATCH] Optimize DescendantsArray insertions --- activesupport/lib/active_support/descendants_tracker.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb index 1dad4f923ef96..b14842bf67f78 100644 --- a/activesupport/lib/active_support/descendants_tracker.rb +++ b/activesupport/lib/active_support/descendants_tracker.rb @@ -77,15 +77,17 @@ def initialize_copy(orig) 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