]> gitweb.factorcode.org Git - factor.git/commitdiff
math.bitwise: don't count the same bits over&over
authorJoe Groff <arcata@gmail.com>
Sat, 12 Nov 2011 07:36:21 +0000 (23:36 -0800)
committerJoe Groff <arcata@gmail.com>
Mon, 14 Nov 2011 00:10:22 +0000 (16:10 -0800)
basis/math/bitwise/bitwise.factor

index a0d19b49ec351ef77a583d2b76375de963f0b42f..4dc99e47ecd596080e15e6e2bd794985c081eb5a 100644 (file)
@@ -90,13 +90,13 @@ GENERIC: (bit-count) ( x -- n )
     { fixnum } declare
     [ byte-bit-count ] keep
     [ -8 shift byte-bit-count + ] keep
-    [ -8 shift byte-bit-count + ] keep
-    [ -8 shift byte-bit-count + ] keep
+    [ -16 shift byte-bit-count + ] keep
+    [ -24 shift byte-bit-count + ] keep
     cell 8 = [
-        [ -8 shift byte-bit-count + ] keep
-        [ -8 shift byte-bit-count + ] keep
-        [ -8 shift byte-bit-count + ] keep
-          -8 shift byte-bit-count + >fixnum
+        [ -32 shift byte-bit-count + ] keep
+        [ -40 shift byte-bit-count + ] keep
+        [ -48 shift byte-bit-count + ] keep
+          -56 shift byte-bit-count + >fixnum
     ] [ drop ] if ;
 
 M: fixnum (bit-count)