]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: faster /rem.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 07:12:16 +0000 (23:12 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 07:12:16 +0000 (23:12 -0800)
basis/calendar/calendar.factor

index a95baf990ec0c2711e80b28b0d95457824132e08..40d1812ded94f5faa80e1a9caef2640c7fb5b270 100644 (file)
@@ -194,7 +194,7 @@ GENERIC: +second ( timestamp x -- timestamp )
 
 : /rem ( f n -- q r )
     ! q is positive or negative, r is positive from 0 <= r < n
-    [ / floor >integer ] 2keep rem ;
+    [ /mod ] keep over 0 < [ + [ -1 + ] dip ] [ drop ] if ;
 
 : float>whole-part ( float -- int float )
     [ floor >integer ] keep over - ;