summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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