bloom-filters: minor style improvements.

db4
John Benediktsson 2013-04-03 15:20:49 -07:00
parent 2e40bffccf
commit 8c8d8d0c14
1 changed files with 6 additions and 9 deletions

View File

@ -72,8 +72,8 @@ ERROR: invalid-n-objects n-objects ;
! If the number of hashes isn't positive, we haven't found ! If the number of hashes isn't positive, we haven't found
! anything smaller than the identity configuration. ! anything smaller than the identity configuration.
: validate-sizes ( 2seq -- ) : check-capacity ( 2seq -- 2seq )
first 0 <= [ capacity-error ] when ; dup first 0 <= [ capacity-error ] when ;
! The consensus on the tradeoff between increasing the number of ! The consensus on the tradeoff between increasing the number of
! bits and increasing the number of hash functions seems to be ! bits and increasing the number of hash functions seems to be
@ -83,14 +83,11 @@ ERROR: invalid-n-objects n-objects ;
! seen any usage studies from the implementations that made this ! seen any usage studies from the implementations that made this
! tradeoff to support it, and I haven't done my own, but we'll ! tradeoff to support it, and I haven't done my own, but we'll
! go with it anyway. ! go with it anyway.
!
: size-bloom-filter ( error-rate number-objects -- number-hashes number-bits ) : size-bloom-filter ( error-rate number-objects -- number-hashes number-bits )
[ n-hashes-range identity-configuration ] 2dip [ n-hashes-range identity-configuration ] 2dip '[
'[ dup [ _ _ bits-to-satisfy-error-rate ] dup _ _ bits-to-satisfy-error-rate
call 2array smaller-second ] 2array smaller-second
reduce ] reduce check-capacity first2 ;
dup validate-sizes
first2 ;
: check-n-objects ( n-objects -- n-objects ) : check-n-objects ( n-objects -- n-objects )
dup 0 <= [ invalid-n-objects ] when ; dup 0 <= [ invalid-n-objects ] when ;