From e71e1bc50e5277ea1c276e6dd1f76bf12c6973fa Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 1 Jan 2024 23:05:12 +0900 Subject: [PATCH] mruby-hash-ext: reduce the scope of the loop variable `i` --- mrbgems/mruby-hash-ext/src/hash-ext.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mrbgems/mruby-hash-ext/src/hash-ext.c b/mrbgems/mruby-hash-ext/src/hash-ext.c index b634373f4..7ec21c61c 100644 --- a/mrbgems/mruby-hash-ext/src/hash-ext.c +++ b/mrbgems/mruby-hash-ext/src/hash-ext.c @@ -24,14 +24,14 @@ hash_values_at(mrb_state *mrb, mrb_value hash) { const mrb_value *argv; mrb_value result; - mrb_int argc, i; + mrb_int argc; int ai; mrb_get_args(mrb, "*", &argv, &argc); result = mrb_ary_new_capa(mrb, argc); if (argc == 0) return result; ai = mrb_gc_arena_save(mrb); - for (i = 0; i < argc; i++) { + for (mrb_int i = 0; i < argc; i++) { mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i])); mrb_gc_arena_restore(mrb, ai); } @@ -53,12 +53,12 @@ hash_slice(mrb_state *mrb, mrb_value hash) { const mrb_value *argv; mrb_value result; - mrb_int argc, i; + mrb_int argc; mrb_get_args(mrb, "*", &argv, &argc); result = mrb_hash_new_capa(mrb, argc); if (argc == 0) return result; /* empty hash */ - for (i = 0; i < argc; i++) { + for (mrb_int i = 0; i < argc; i++) { mrb_value key = argv[i]; mrb_value val; @@ -85,11 +85,11 @@ hash_except(mrb_state *mrb, mrb_value hash) { const mrb_value *argv; mrb_value result; - mrb_int argc, i; + mrb_int argc; mrb_get_args(mrb, "*", &argv, &argc); result = mrb_hash_dup(mrb, hash); - for (i = 0; i < argc; i++) { + for (mrb_int i = 0; i < argc; i++) { mrb_hash_delete_key(mrb, result, argv[i]); } return result;