From 3aef5ce9b35a4659379201eb6bb1dba355a83ba4 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 13 Sep 2012 14:13:19 -0700 Subject: [PATCH] Freeze columns before using them as hash keys This reduces the number of allocated strings from columns * (rows + 1) to just columns. --- activerecord/lib/active_record/result.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 2414a4bbd7..5011a0d75d 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -11,7 +11,7 @@ module ActiveRecord attr_reader :columns, :rows, :column_types def initialize(columns, rows, column_types = {}) - @columns = columns + @columns = columns.map{|c| c.freeze} @rows = rows @hash_rows = nil @column_types = column_types