[前][次][番号順一覧][スレッド一覧]

ruby-changes:29670

From: nobu <ko1@a...>
Date: Mon, 1 Jul 2013 15:05:15 +0900 (JST)
Subject: [ruby-changes:29670] nobu:r41722 (trunk): csv.rb: get rid of discarding coderange

nobu	2013-07-01 15:05:03 +0900 (Mon, 01 Jul 2013)

  New Revision: 41722

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41722

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/lib/csv.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41721)
+++ ChangeLog	(revision 41722)
@@ -1,4 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Mon Jul  1 15:04:20 2013  Nobuyoshi Nakada  <nobu@r...>
+Mon Jul  1 15:05:00 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
Index: lib/csv.rb
===================================================================
--- lib/csv.rb	(revision 41721)
+++ lib/csv.rb	(revision 41722)
@@ -1655,7 +1655,7 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1655
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]