Skip to content

Commit

Permalink
Freeze columns only once per Result
Browse files Browse the repository at this point in the history
Conflicts:
	activerecord/lib/active_record/result.rb
  • Loading branch information
spastorino authored and tenderlove committed Mar 3, 2013
1 parent 2e2f8c0 commit d2b9862
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions activerecord/lib/active_record/result.rb
Expand Up @@ -26,9 +26,15 @@ def to_hash


private private
def hash_rows def hash_rows
@hash_rows ||= @rows.map { |row| @hash_rows ||=
Hash[@columns.zip(row)] 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 end
end end

0 comments on commit d2b9862

Please sign in to comment.