summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-02-17 23:28:00 +0900
committerNobuyoshi Nakada <[email protected]>2024-02-17 23:28:00 +0900
commit3dccb716daaee74d2ae00a5766fe1779fe220a81 (patch)
tree00cd2aeea7706eebaff32c2729e83dba4c29376b /numeric.c
parentdf63e5bef67ff74216834f61748aa6ea8b0de22e (diff)
Use `defined?(yield)` and `SIZED_ENUMERATOR`
Prefer built-in features over method calls that may be overridden.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 5a8d40101d..5c28618a1a 100644
--- a/numeric.c
+++ b/numeric.c
@@ -5664,6 +5664,12 @@ int_downto(VALUE from, VALUE to)
return from;
}
+static VALUE
+int_dotimes_size(VALUE num, VALUE args, VALUE eobj)
+{
+ return int_neg_p(num) ? INT2FIX(0) : num;
+}
+
/*
* call-seq:
* round(ndigits= 0, half: :up) -> integer