Freeze columns only once per Result

This commit is contained in:
Santiago Pastorino 2012-09-20 12:59:31 -03:00
parent 883fa8f938
commit da400fbb0b
1 changed files with 9 additions and 6 deletions

View File

@ -53,12 +53,15 @@ module ActiveRecord
private
def hash_rows
@hash_rows ||= @rows.map { |row|
# We freeze the strings to prevent them getting duped when
# used as keys in ActiveRecord::Model's @attributes hash
columns = @columns.map { |c| c.freeze }
Hash[columns.zip(row)]
}
@hash_rows ||=
begin
# We freeze the strings to prevent them getting duped when
# used as keys in ActiveRecord::Model's @attributes hash
columns = @columns.map { |c| c.dup.freeze }
@rows.map { |row|
Hash[columns.zip(row)]
}
end
end
end
end