ruby-changes:74227
From: Yusuke <ko1@a...>
Date: Mon, 24 Oct 2022 18:13:41 +0900 (JST)
Subject: [ruby-changes:74227] ef01482f64 (master): Refactor timeout-related code in re.c a little
https://git.ruby-lang.org/ruby.git/commit/?id=ef01482f64 From ef01482f64df9bcd7adb2b64ca6ab96f55f42c43 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Mon, 24 Oct 2022 18:12:49 +0900 Subject: Refactor timeout-related code in re.c a little --- re.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/re.c b/re.c index c1214f392a..b21def1b7b 100644 --- a/re.c +++ b/re.c @@ -3848,11 +3848,11 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/re.c#L3848 regex_t *reg = RREGEXP_PTR(self); { - double limit = NIL_P(timeout) ? 0.0 : NUM2DBL(timeout); - if (!NIL_P(timeout) && limit <= 0) { + double timeout_d = NIL_P(timeout) ? 0.0 : NUM2DBL(timeout); + if (!NIL_P(timeout) && timeout_d <= 0) { rb_raise(rb_eArgError, "invalid timeout: %"PRIsVALUE, timeout); } - double2hrtime(®->timelimit, limit); + double2hrtime(®->timelimit, timeout_d); } return self; @@ -4476,18 +4476,18 @@ rb_reg_s_timeout_get(VALUE dummy) https://github.com/ruby/ruby/blob/trunk/re.c#L4476 */ static VALUE -rb_reg_s_timeout_set(VALUE dummy, VALUE limit) +rb_reg_s_timeout_set(VALUE dummy, VALUE timeout) { - double timeout = NIL_P(limit) ? 0.0 : NUM2DBL(limit); + double timeout_d = NIL_P(timeout) ? 0.0 : NUM2DBL(timeout); rb_ractor_ensure_main_ractor("can not access Regexp.timeout from non-main Ractors"); - if (!NIL_P(limit) && timeout <= 0) { - rb_raise(rb_eArgError, "invalid timeout: %"PRIsVALUE, limit); + if (!NIL_P(timeout) && timeout_d <= 0) { + rb_raise(rb_eArgError, "invalid timeout: %"PRIsVALUE, timeout); } - double2hrtime(&rb_reg_match_time_limit, timeout); + double2hrtime(&rb_reg_match_time_limit, timeout_d); - return limit; + return timeout; } /* -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/