Skip to content

Commit

Permalink
Removed intermediate local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jul 16, 2019
1 parent 8e37ef7 commit 00dc0da
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions class.c
Expand Up @@ -1871,27 +1871,20 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V

#define extract_kwarg(keyword, val) \
(key = (st_data_t)(keyword), values ? \
rb_hash_stlike_delete(keyword_hash, &key, (val)) : \
rb_hash_stlike_lookup(keyword_hash, key, (val)))
(rb_hash_stlike_delete(keyword_hash, &key, &(val)) || ((val) = Qundef, 0)) : \
rb_hash_stlike_lookup(keyword_hash, key, NULL))

if (NIL_P(keyword_hash)) keyword_hash = 0;

if (optional < 0) {
rest = 1;
optional = -1-optional;
}
if (values) {
for (j = 0; j < required + optional; j++) {
values[j] = Qundef;
}
}
if (required) {
for (; i < required; i++) {
VALUE keyword = ID2SYM(table[i]);
if (keyword_hash) {
st_data_t val;
if (extract_kwarg(keyword, &val)) {
if (values) values[i] = (VALUE)val;
if (extract_kwarg(keyword, values[i])) {
continue;
}
}
Expand All @@ -1905,9 +1898,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
j = i;
if (optional && keyword_hash) {
for (i = 0; i < optional; i++) {
st_data_t val;
if (extract_kwarg(ID2SYM(table[required+i]), &val)) {
if (values) values[required+i] = (VALUE)val;
if (extract_kwarg(ID2SYM(table[required+i]), values[required+i])) {
j++;
}
}
Expand All @@ -1917,6 +1908,11 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
unknown_keyword_error(keyword_hash, table, required+optional);
}
}
if (values && !keyword_hash) {
for (i = 0; i < required + optional; i++) {
values[i] = Qundef;
}
}
return j;
#undef extract_kwarg
}
Expand Down

0 comments on commit 00dc0da

Please sign in to comment.