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

ruby-changes:5598

From: matz <ko1@a...>
Date: Thu, 12 Jun 2008 08:52:37 +0900 (JST)
Subject: [ruby-changes:5598] Ruby:r17104 (trunk): * io.c (read_all): should use io_read_encoding(), not

matz	2008-06-12 08:52:20 +0900 (Thu, 12 Jun 2008)

  New Revision: 17104

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/string.c

  Log:
    * io.c (read_all): should use io_read_encoding(), not
      io_input_encoding().
    
    * io.c (rb_io_getline_1): reduce calling of io_read_encoding().
    
    * string.c (rb_str_scan): need not to restore $~ value, so avoid
      pinning match object.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=17104&r2=17103&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17104&r2=17103&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=17104&r2=17103&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17103)
+++ ChangeLog	(revision 17104)
@@ -1,3 +1,13 @@
+Thu Jun 12 08:47:51 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (read_all): should use io_read_encoding(), not
+	  io_input_encoding().
+
+	* io.c (rb_io_getline_1): reduce calling of io_read_encoding().
+
+	* string.c (rb_str_scan): need not to restore $~ value, so avoid
+	  pinning match object.
+
 Thu Jun 12 02:49:40 2008  Yusuke Endoh  <mame@t...>
 
 	* ext/stringio/stringio.c (strio_init): rewind when reopened.
Index: string.c
===================================================================
--- string.c	(revision 17103)
+++ string.c	(revision 17104)
@@ -5705,11 +5705,8 @@
     }
 
     while (!NIL_P(result = scan_once(str, pat, &start))) {
-	match = rb_backref_get();
-	rb_match_busy(match);
 	rb_yield(result);
 	str_mod_check(str, p, len);
-	rb_backref_set(match);	/* restore $~ value */
     }
     rb_backref_set(match);
     return str;
Index: io.c
===================================================================
--- io.c	(revision 17103)
+++ io.c	(revision 17104)
@@ -1397,7 +1397,7 @@
     long bytes = 0;
     long n;
     long pos = 0;
-    rb_encoding *enc = io_input_encoding(fptr);
+    rb_encoding *enc = io_read_encoding(fptr);
     int cr = fptr->enc2 ? ENC_CODERANGE_BROKEN : 0;
 
     if (siz == 0) siz = BUFSIZ;
@@ -1835,12 +1835,11 @@
 }
 
 static VALUE
-rb_io_getline_fast(rb_io_t *fptr)
+rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
 {
     VALUE str = Qnil;
     int len = 0;
     long pos = 0;
-    rb_encoding *enc = io_input_encoding(fptr);
     int cr = fptr->enc2 ? ENC_CODERANGE_BROKEN : 0;
 
     for (;;) {
@@ -1950,7 +1949,6 @@
 
     GetOpenFile(io, fptr);
     rb_io_check_readable(fptr);
-    enc = io_input_encoding(fptr);
     if (NIL_P(rs)) {
 	str = read_all(fptr, 0, Qnil);
 	if (RSTRING_LEN(str) == 0) return Qnil;
@@ -1959,8 +1957,8 @@
 	return rb_enc_str_new(0, 0, io_read_encoding(fptr));
     }
     else if (rs == rb_default_rs && limit < 0 &&
-             rb_enc_asciicompat(io_read_encoding(fptr))) {
-	return rb_io_getline_fast(fptr);
+             rb_enc_asciicompat(enc = io_read_encoding(fptr))) {
+	return rb_io_getline_fast(fptr, enc);
     }
     else {
 	int c, newline;
@@ -1981,6 +1979,7 @@
 	}
 	newline = rsptr[rslen - 1];
 
+	enc = io_input_encoding(fptr);
 	while ((c = appendline(fptr, newline, &str, &limit)) != EOF) {
 	    if (c == newline) {
 		const char *s, *p, *pp;
@@ -2034,7 +2033,7 @@
 
     GetOpenFile(io, fptr);
     rb_io_check_readable(fptr);
-    return rb_io_getline_fast(fptr);
+    return rb_io_getline_fast(fptr, io_read_encoding(fptr));
 }
 
 /*

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

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