Skip to content

Commit 4de5752

Browse files
committed
Remove check for nil kw_args, use rb_intern_const instead of CONST_ID
See code review comments in ruby/openssl#996
1 parent 0b5374c commit 4de5752

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

ext/extralite/database.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,19 +1160,18 @@ struct progress_handler parse_progress_handler_opts(VALUE opts) {
11601160
.tick = DEFAULT_PROGRESS_HANDLER_TICK
11611161
};
11621162

1163-
if (!NIL_P(opts)) {
1164-
if (!kw_ids[0]) {
1165-
CONST_ID(kw_ids[0], "period");
1166-
CONST_ID(kw_ids[1], "tick");
1167-
CONST_ID(kw_ids[2], "mode");
1168-
}
1169-
1170-
rb_get_kwargs(opts, kw_ids, 0, 3, kw_args);
1171-
if (kw_args[0] != Qundef) { prog.period = NUM2INT(kw_args[0]); }
1172-
if (kw_args[1] != Qundef) { prog.tick = NUM2INT(kw_args[1]); }
1173-
if (kw_args[2] != Qundef) { prog.mode = symbol_to_progress_mode(kw_args[2]); }
1174-
if (prog.tick > prog.period) prog.tick = prog.period;
1163+
if (!kw_ids[0]) {
1164+
kw_ids[0] = rb_intern_const("period");
1165+
kw_ids[1] = rb_intern_const("tick");
1166+
kw_ids[2] = rb_intern_const("mode");
11751167
}
1168+
1169+
rb_get_kwargs(opts, kw_ids, 0, 3, kw_args);
1170+
if (kw_args[0] != Qundef) { prog.period = NUM2INT(kw_args[0]); }
1171+
if (kw_args[1] != Qundef) { prog.tick = NUM2INT(kw_args[1]); }
1172+
if (kw_args[2] != Qundef) { prog.mode = symbol_to_progress_mode(kw_args[2]); }
1173+
if (prog.tick > prog.period) prog.tick = prog.period;
1174+
11761175
if (NIL_P(prog.proc) || (prog.period <= 0)) prog.mode = PROGRESS_NONE;
11771176
if (prog.mode == PROGRESS_NONE) prog.proc = Qnil;
11781177

0 commit comments

Comments
 (0)