mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
8776802385
commit
45c2532e59
2 changed files with 7 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue