aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2015-05-15 09:38:25 -0400
committerTamir Duberstein <tamird@gmail.com>2016-01-04 07:58:32 -0500
commita08dc46a0e90963fead04ab7285693def0397e42 (patch)
treeb52d473c53dbed458ad1bab4656a5629228c2e27 /activerecord
parent3d590add45b7ff1de972d99b076cb504d5208935 (diff)
downloadrails-a08dc46a0e90963fead04ab7285693def0397e42.tar.gz
rails-a08dc46a0e90963fead04ab7285693def0397e42.tar.bz2
rails-a08dc46a0e90963fead04ab7285693def0397e42.zip
activerecord: allocate fewer arrays in `RecordFetchWarning`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/record_fetch_warning.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/record_fetch_warning.rb b/activerecord/lib/active_record/relation/record_fetch_warning.rb
index 0a1814b3dd..dbd08811fa 100644
--- a/activerecord/lib/active_record/relation/record_fetch_warning.rb
+++ b/activerecord/lib/active_record/relation/record_fetch_warning.rb
@@ -24,9 +24,7 @@ module ActiveRecord
end
# :stopdoc:
- ActiveSupport::Notifications.subscribe("sql.active_record") do |*args|
- payload = args.last
-
+ ActiveSupport::Notifications.subscribe("sql.active_record") do |*, payload|
QueryRegistry.queries << payload[:sql]
end
# :startdoc:
@@ -34,14 +32,14 @@ module ActiveRecord
class QueryRegistry # :nodoc:
extend ActiveSupport::PerThreadRegistry
- attr_accessor :queries
+ attr_reader :queries
def initialize
- reset
+ @queries = []
end
def reset
- @queries = []
+ @queries.clear
end
end
end