]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "math: speed up integer>fixnum operations."
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 16 Sep 2012 14:46:22 +0000 (07:46 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 16 Sep 2012 14:46:22 +0000 (07:46 -0700)
This reverts commit b467db9a9aecce0a4ae9ddc7ed811f16b1ac4eae.

core/math/integers/integers.factor
core/math/math.factor

index 81dedc66dd969e70a207e8de9aedbd0021f26bd5..27253b6da7200a5546b33b4c7fb37342157023e4 100644 (file)
@@ -15,6 +15,8 @@ M: fixnum >fixnum ; inline
 M: fixnum >bignum fixnum>bignum ; inline
 M: fixnum >integer ; inline
 M: fixnum >float fixnum>float ; inline
+M: fixnum integer>fixnum ; inline
+M: fixnum integer>fixnum-strict ; inline
 
 M: fixnum hashcode* nip ; inline
 M: fixnum equal? over bignum? [ >bignum bignum= ] [ 2drop f ] if ; inline
@@ -61,6 +63,11 @@ M: fixnum (log2) fixnum-log2 ; inline
 
 M: bignum >fixnum bignum>fixnum ; inline
 M: bignum >bignum ; inline
+M: bignum integer>fixnum bignum>fixnum ; inline
+
+M: bignum integer>fixnum-strict
+    dup bignum>fixnum
+    2dup number= [ nip ] [ drop out-of-fixnum-range ] if ; inline
 
 M: bignum hashcode* nip bignum>fixnum ;
 
index dcedc67963491cd31c3098c8dc3f1bbb92ce4204..20593bd48a89e1db518b1e3acf91e687f84adc9c 100644 (file)
@@ -7,6 +7,8 @@ GENERIC: >fixnum ( x -- n ) foldable
 GENERIC: >bignum ( x -- n ) foldable
 GENERIC: >integer ( x -- n ) foldable
 GENERIC: >float ( x -- y ) foldable
+GENERIC: integer>fixnum ( x -- y ) foldable
+GENERIC: integer>fixnum-strict ( x -- y ) foldable
 
 GENERIC: numerator ( a/b -- a )
 GENERIC: denominator ( a/b -- b )
@@ -56,8 +58,6 @@ GENERIC: (log2) ( x -- n ) foldable
 
 PRIVATE>
 
-ERROR: not-an-integer n ;
-
 ERROR: out-of-fixnum-range n ;
 
 ERROR: log2-expects-positive x ;
@@ -87,19 +87,6 @@ GENERIC: neg? ( x -- -x )
 
 UNION: integer fixnum bignum ;
 
-: integer>fixnum ( m -- n )
-    dup fixnum? [
-        dup bignum? [ bignum>fixnum ] [ not-an-integer ] if
-    ] unless ; inline foldable
-
-: integer>fixnum-strict ( m -- n )
-    dup fixnum? [
-        dup bignum? [
-            dup bignum>fixnum 2dup number=
-            [ nip ] [ drop out-of-fixnum-range ] if
-        ] [ not-an-integer ] if
-    ] unless ; inline foldable
-
 TUPLE: ratio { numerator integer read-only } { denominator integer read-only } ;
 
 UNION: rational integer ratio ;