mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
1a5bc2864d
commit
72f60a2ff1
1 changed files with 8 additions and 2 deletions
10
class.c
10
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue