bit-arrays: fix resize method regression after recent equal? method optimization

db4
Slava Pestov 2009-07-29 06:47:50 -05:00
parent 34432c5f18
commit f3fa4debe3
1 changed files with 14 additions and 1 deletions

View File

@ -27,6 +27,18 @@ TUPLE: bit-array
[ [ length bits>cells ] keep ] dip swap underlying>> [ [ length bits>cells ] keep ] dip swap underlying>>
'[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each ; inline '[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each ; inline
: clean-up ( bit-array -- )
! Zero bits after the end.
dup underlying>> empty? [ drop ] [
[
[ underlying>> length 8 * ] [ length ] bi -
8 swap - -1 swap shift bitnot
]
[ underlying>> last bitand ]
[ underlying>> set-last ]
tri
] if ; inline
PRIVATE> PRIVATE>
: <bit-array> ( n -- bit-array ) : <bit-array> ( n -- bit-array )
@ -68,7 +80,8 @@ M: bit-array resize
[ bits>bytes ] [ underlying>> ] bi* [ bits>bytes ] [ underlying>> ] bi*
resize-byte-array resize-byte-array
] 2bi ] 2bi
bit-array boa ; bit-array boa
dup clean-up ;
M: bit-array byte-length length 7 + -3 shift ; M: bit-array byte-length length 7 + -3 shift ;