Skip to content

Commit

Permalink
math.integers: faster fixnum-log2.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Feb 28, 2013
1 parent df54ef2 commit 4da316c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/math/integers/integers.factor
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ M: fixnum bitnot fixnum-bitnot ; inline
M: fixnum bit? fixnum-bit? ; inline

: fixnum-log2 ( x -- n )
0 swap [ dup 1 eq? ] [ [ 1 + ] [ 2/ ] bi* ] until drop ; inline
0 swap [ dup 1 eq? ] [
[ 1 fixnum+fast ] [ 2/ ] bi*
] until drop ; inline

M: fixnum (log2) fixnum-log2 ; inline

Expand Down

0 comments on commit 4da316c

Please sign in to comment.