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

ruby-changes:31989

From: nobu <ko1@a...>
Date: Sun, 8 Dec 2013 16:17:29 +0900 (JST)
Subject: [ruby-changes:31989] nobu:r44068 (trunk): class.c: optimization just one key

nobu	2013-12-08 16:17:21 +0900 (Sun, 08 Dec 2013)

  New Revision: 44068

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

  Log:
    class.c: optimization just one key
    
    * class.c (keyword_error): use only element itself for
      optimization in the case the key has just one element.

  Modified files:
    trunk/class.c
Index: class.c
===================================================================
--- class.c	(revision 44067)
+++ class.c	(revision 44068)
@@ -1857,8 +1857,14 @@ NORETURN(static void keyword_error(const https://github.com/ruby/ruby/blob/trunk/class.c#L1857
 static void
 keyword_error(const char *error, VALUE keys)
 {
-    const char *msg = RARRAY_LEN(keys) == 1 ? "" : "s";
-    keys = rb_ary_join(keys, rb_usascii_str_new2(", "));
+    const char *msg = "";
+    if (RARRAY_LEN(keys) == 1) {
+	keys = RARRAY_AREF(keys, 0);
+    }
+    else {
+	keys = rb_ary_join(keys, rb_usascii_str_new2(", "));
+	msg = "s";
+    }
     rb_raise(rb_eArgError, "%s keyword%s: %"PRIsVALUE, error, msg, keys);
 }
 

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

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