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

ruby-changes:33501

From: nobu <ko1@a...>
Date: Mon, 14 Apr 2014 14:33:46 +0900 (JST)
Subject: [ruby-changes:33501] nobu:r45582 (trunk): string.c: reduce function calls

nobu	2014-04-14 14:33:42 +0900 (Mon, 14 Apr 2014)

  New Revision: 45582

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

  Log:
    string.c: reduce function calls
    
    * string.c (rb_enc_cr_str_buf_cat): reduce invariant function
      calls of rb_enc_from_index.

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 45581)
+++ string.c	(revision 45582)
@@ -2086,6 +2086,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const c https://github.com/ruby/ruby/blob/trunk/string.c#L2086
     int str_encindex = ENCODING_GET(str);
     int res_encindex;
     int str_cr, res_cr;
+    rb_encoding *str_enc, *ptr_enc;
 
     str_cr = RSTRING_LEN(str) ? ENC_CODERANGE(str) : ENC_CODERANGE_7BIT;
 
@@ -2095,8 +2096,8 @@ rb_enc_cr_str_buf_cat(VALUE str, const c https://github.com/ruby/ruby/blob/trunk/string.c#L2096
         }
     }
     else {
-        rb_encoding *str_enc = rb_enc_from_index(str_encindex);
-        rb_encoding *ptr_enc = rb_enc_from_index(ptr_encindex);
+	str_enc = rb_enc_from_index(str_encindex);
+	ptr_enc = rb_enc_from_index(ptr_encindex);
         if (!rb_enc_asciicompat(str_enc) || !rb_enc_asciicompat(ptr_enc)) {
             if (len == 0)
                 return str;
@@ -2122,10 +2123,11 @@ rb_enc_cr_str_buf_cat(VALUE str, const c https://github.com/ruby/ruby/blob/trunk/string.c#L2123
     if (str_encindex != ptr_encindex &&
         str_cr != ENC_CODERANGE_7BIT &&
         ptr_cr != ENC_CODERANGE_7BIT) {
+	str_enc = rb_enc_from_index(str_encindex);
+	ptr_enc = rb_enc_from_index(ptr_encindex);
       incompatible:
         rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
-            rb_enc_name(rb_enc_from_index(str_encindex)),
-            rb_enc_name(rb_enc_from_index(ptr_encindex)));
+		 rb_enc_name(str_enc), rb_enc_name(ptr_enc));
     }
 
     if (str_cr == ENC_CODERANGE_UNKNOWN) {

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

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