summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-24 00:44:41 +0000
committerjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-24 00:44:41 +0000
commit895e9b0acd986cf3dba7df60fb00c5ca3607c844 (patch)
tree77fc34aee486de9e092b82b7427d8d7f461b2128 /lib
parent34176b023eb42478bad22481d90d6223b5a31d48 (diff)
* lib/csv.rb: Optimize header hashes by freezing string keys.
[ruby-core:58510] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/csv.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/csv.rb b/lib/csv.rb
index d66b84922a..a4d8e3d0a8 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -235,6 +235,7 @@ class CSV
#
def initialize(headers, fields, header_row = false)
@header_row = header_row
+ headers.each { |h| h.freeze if h.is_a? String }
# handle extra headers or fields
@row = if headers.size > fields.size
@@ -2208,6 +2209,7 @@ class CSV
# prepare converted and unconverted copies
row = @headers if row.nil?
@headers = convert_fields(@headers, true)
+ @headers.each { |h| h.freeze if h.is_a? String }
if @return_headers # return headers
return self.class::Row.new(@headers, row, true)