summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-01 06:05:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-01 06:05:03 +0000
commit45c2532e5928e1fd47656179597d6d2aa902cf21 (patch)
tree4c315286191fee559a780f301c09a7906d7e964a
parent8776802385c3d87966d32a6171857abb7dac6998 (diff)
csv.rb: get rid of discarding coderange
* lib/csv.rb (CSV#<<): use StringIO#set_encoding instead of creating new StringIO instance with String#force_encoding, forcing encoding discards the cached coderange bits and can make further operations very slow. [ruby-core:55714] [Bug #8585] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/csv.rb2
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 261d426c90d..0c54ae66f82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-Mon Jul 1 15:04:20 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jul 1 15:05:00 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/csv.rb (CSV#<<): use StringIO#set_encoding instead of creating
+ new StringIO instance with String#force_encoding, forcing encoding
+ discards the cached coderange bits and can make further operations
+ very slow. [ruby-core:55714] [Bug #8585]
* ext/stringio/stringio.c (strio_write): keep coderange of
ptr->string.
diff --git a/lib/csv.rb b/lib/csv.rb
index fe153153be3..b6d91211461 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1655,7 +1655,7 @@ class CSV
if @io.is_a?(StringIO) and
output.encoding != raw_encoding and
(compatible_encoding = Encoding.compatible?(@io.string, output))
- @io = StringIO.new(@io.string.force_encoding(compatible_encoding))
+ @io.set_encoding(compatible_encoding)
@io.seek(0, IO::SEEK_END)
end
@io << output