diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-16 08:48:57 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-16 09:15:25 +0900 |
commit | 00dc0dae0d7b247a917f5b676a777db86cdf1f3a (patch) | |
tree | f96eb5c3fe570cd1ff5f2b198628fcb381960c0b | |
parent | 8e37ef76f6f640178ffaea4d7c0d36a17e6ca171 (diff) | |
download | ruby-00dc0dae0d7b247a917f5b676a777db86cdf1f3a.tar.gz |
Removed intermediate local variables
-rw-r--r-- | class.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -1871,8 +1871,8 @@ 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; @@ -1880,18 +1880,11 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V 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; } } @@ -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++; } } @@ -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 } |