1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Freeze columns before using them as hash keys

This reduces the number of allocated strings from columns * (rows + 1) to just columns.
This commit is contained in:
Jeremy Evans 2012-09-13 14:13:19 -07:00
parent 0247443deb
commit 3aef5ce9b3

View file

@ -11,7 +11,7 @@ module ActiveRecord
attr_reader :columns, :rows, :column_types attr_reader :columns, :rows, :column_types
def initialize(columns, rows, column_types = {}) def initialize(columns, rows, column_types = {})
@columns = columns @columns = columns.map{|c| c.freeze}
@rows = rows @rows = rows
@hash_rows = nil @hash_rows = nil
@column_types = column_types @column_types = column_types