ruby-changes:59907
From: Nobuyoshi <ko1@a...>
Date: Sun, 2 Feb 2020 23:09:55 +0900 (JST)
Subject: [ruby-changes:59907] fae537259d (master): Removed no longer used variable `last_hash`
https://git.ruby-lang.org/ruby.git/commit/?id=fae537259d From fae537259da3dd61fb62ae65d382a0ddc7c215dc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 2 Feb 2020 23:09:25 +0900 Subject: Removed no longer used variable `last_hash` 1. By substituting `n_var` with its initializer, `0 < n_var` is equivalent to `argc > argi + n_trail`. 2. As `argi` is non-negative, so `argi + n_trail >= n_trail`, and the above expression is equivalent to `argc > n_trail`. 3. Therefore, `f_last` is always false, and `last_hash` is no longer used. diff --git a/class.c b/class.c index 46f7cc3..16b4a44 100644 --- a/class.c +++ b/class.c @@ -1964,7 +1964,6 @@ struct rb_scan_args_t { https://github.com/ruby/ruby/blob/trunk/class.c#L1964 int n_mand; int argi; VALUE hash; - VALUE last_hash; }; static void @@ -2065,11 +2064,7 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs) https://github.com/ruby/ruby/blob/trunk/class.c#L2064 var = va_arg(vargs, VALUE *); if (0 < n_var) { - if (var) { - int f_last = (arg->argc == arg->n_trail); - *var = rb_ary_new4(n_var - f_last, &arg->argv[argi]); - if (f_last) rb_ary_push(*var, arg->last_hash); - } + if (var) *var = rb_ary_new4(n_var, &arg->argv[argi]); argi += n_var; } else { diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index dc1eb29..3402d73 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2482,7 +2482,7 @@ rb_scan_args_set(int argc, const VALUE *argv, https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2482 # endif { int i, argi = 0, vari = 0; - VALUE *var, hash = Qnil, last_hash = 0; + VALUE *var, hash = Qnil; const int n_mand = n_lead + n_trail; if (f_hash && argc > 0 && rb_keyword_given_p()) { @@ -2517,11 +2517,7 @@ rb_scan_args_set(int argc, const VALUE *argv, https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2517 var = vars[vari++]; if (0 < n_var) { - if (var) { - int f_last = (argc == n_trail); - *var = rb_ary_new4(n_var-f_last, &argv[argi]); - if (f_last) rb_ary_push(*var, last_hash); - } + if (var) *var = rb_ary_new4(n_var, &argv[argi]); argi += n_var; } else { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/