From 784177aeeeea3265e74b2ec8c3a2929a160ba904 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 20 Oct 2010 16:17:15 -0700 Subject: only call `column_methods_hash` once, use array math for faster test of existence --- activerecord/lib/active_record/base.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 630bf7fe85..9c4bded1f3 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -991,19 +991,18 @@ module ActiveRecord #:nodoc: attribute_names.each do |attribute_name| unless (aggregation = reflect_on_aggregation(attribute_name.to_sym)).nil? aggregate_mapping(aggregation).each do |field_attr, aggregate_attr| - expanded_attribute_names << field_attr + expanded_attribute_names << field_attr.to_sym end else - expanded_attribute_names << attribute_name + expanded_attribute_names << attribute_name.to_sym end end expanded_attribute_names end def all_attributes_exists?(attribute_names) - expand_attribute_names_for_aggregates(attribute_names).all? { |name| - column_methods_hash.include?(name.to_sym) - } + (expand_attribute_names_for_aggregates(attribute_names) - + column_methods_hash.keys).empty? end protected -- cgit v1.2.3