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

ruby-changes:59966

From: Nobuyoshi <ko1@a...>
Date: Sun, 9 Feb 2020 16:10:07 +0900 (JST)
Subject: [ruby-changes:59966] c47cd4be28 (master): Removed duplicated code

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

From c47cd4be28840159251b4c66df71e10e979316a0 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 9 Feb 2020 15:43:15 +0900
Subject: Removed duplicated code


diff --git a/enumerator.c b/enumerator.c
index fa30a59..5d5c382 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -3806,35 +3806,6 @@ arith_seq_each(VALUE self) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L3806
     return self;
 }
 
-static double
-arith_seq_float_step_size(double beg, double end, double step, int excl)
-{
-    double const epsilon = DBL_EPSILON;
-    double n, err;
-
-    if (step == 0) {
-        return HUGE_VAL;
-    }
-    n = (end - beg) / step;
-    err = (fabs(beg) + fabs(end) + fabs(end - beg)) / fabs(step) * epsilon;
-    if (isinf(step)) {
-        return step > 0 ? beg <= end : beg >= end;
-    }
-    if (err > 0.5) err = 0.5;
-    if (excl) {
-        if (n <= 0) return 0;
-        if (n < 1)
-            n = 0;
-        else
-            n = floor(n - err);
-    }
-    else {
-        if (n < 0) return 0;
-        n = floor(n + err);
-    }
-    return n + 1;
-}
-
 /*
  * call-seq:
  *   aseq.size -> num or nil
@@ -3868,7 +3839,7 @@ arith_seq_size(VALUE self) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L3839
             ee = NUM2DBL(e);
         }
 
-        n = arith_seq_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x);
+        n = ruby_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x);
         if (isinf(n)) return DBL2NUM(n);
         if (POSFIXABLE(n)) return LONG2FIX(n);
         return rb_dbl2big(n);
-- 
cgit v0.10.2


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

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