summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-08 07:17:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-08 07:17:21 +0000
commit72f60a2ff1900295b1ff8d10b63b045152475d4f (patch)
treea109d51244417ef494330eb7a859d9e8d44333af /class.c
parent1a5bc2864da5da6f7167dd568624818422e99609 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/class.c b/class.c
index 66495eb..ce5547d 100644
--- a/class.c
+++ b/class.c
@@ -1857,8 +1857,14 @@ NORETURN(static void keyword_error(const char *error, VALUE keys));
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);
}