[前][次][番号順一覧][スレッド一覧]

ruby-changes:59622

From: Kazuhiro <ko1@a...>
Date: Sun, 5 Jan 2020 12:44:48 +0900 (JST)
Subject: [ruby-changes:59622] 787c6d591a (master): Remove unused last_idx in class.c

https://git.ruby-lang.org/ruby.git/commit/?id=787c6d591a

From 787c6d591aa0a170d5f5b714df7aea6de6c5f0a2 Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Sun, 5 Jan 2020 11:52:39 +0900
Subject: Remove unused last_idx in class.c

ref c7f01d889becbeffc4254e1b0b7faecb80ea3f3e and beae6cbf0fd8b6619e5212552de98022d4c4d4d4

diff --git a/class.c b/class.c
index 7db54d6..cda43de 100644
--- a/class.c
+++ b/class.c
@@ -1958,7 +1958,6 @@ struct rb_scan_args_t { https://github.com/ruby/ruby/blob/trunk/class.c#L1958
     int n_trail;
     int n_mand;
     int argi;
-    int last_idx;
     VALUE hash;
     VALUE last_hash;
     VALUE *tmp_buffer;
@@ -1972,7 +1971,6 @@ rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, st https://github.com/ruby/ruby/blob/trunk/class.c#L1971
     int last_hash_keyword = 0;
 
     memset(arg, 0, sizeof(*arg));
-    arg->last_idx = -1;
     arg->hash = Qnil;
 
     switch (kw_flag) {
@@ -2043,14 +2041,14 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs) https://github.com/ruby/ruby/blob/trunk/class.c#L2041
     /* capture leading mandatory arguments */
     for (i = arg->n_lead; i-- > 0; ) {
 	var = va_arg(vargs, VALUE *);
-        if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+        if (var) *var = arg->argv[argi];
 	argi++;
     }
     /* capture optional arguments */
     for (i = arg->n_opt; i-- > 0; ) {
 	var = va_arg(vargs, VALUE *);
         if (argi < arg->argc - arg->n_trail) {
-            if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+            if (var) *var = arg->argv[argi];
 	    argi++;
 	}
 	else {
@@ -2064,7 +2062,7 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs) https://github.com/ruby/ruby/blob/trunk/class.c#L2062
 	var = va_arg(vargs, VALUE *);
 	if (0 < n_var) {
 	    if (var) {
-                int f_last = (arg->last_idx + 1 == arg->argc - arg->n_trail);
+                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);
 	    }
@@ -2077,7 +2075,7 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs) https://github.com/ruby/ruby/blob/trunk/class.c#L2075
     /* capture trailing mandatory arguments */
     for (i = arg->n_trail; i-- > 0; ) {
 	var = va_arg(vargs, VALUE *);
-        if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+        if (var) *var = arg->argv[argi];
 	argi++;
     }
     /* capture an option hash - phase 2: assignment */
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]