Optimize byte-reverse macro in alien.endian -- it was shifting each byte to the 0th bit place, bitand-ing it with HEX: ff, then shifting it to its final destination -- now we immediately shift to the proper location and bitand with the proper bitmask.
parent
250e528209
commit
757889167a
|
@ -18,13 +18,21 @@ ERROR: invalid-signed-conversion n ;
|
||||||
[ invalid-signed-conversion ]
|
[ invalid-signed-conversion ]
|
||||||
} case ; inline
|
} case ; inline
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: byte-mask ( #bits-shift -- mask )
|
||||||
|
[ HEX: ff ] dip shift ; foldable
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
MACRO: byte-reverse ( n signed? -- quot )
|
MACRO: byte-reverse ( n signed? -- quot )
|
||||||
[
|
[
|
||||||
drop
|
drop
|
||||||
[
|
[
|
||||||
dup iota [
|
dup iota [
|
||||||
[ 1 + - -8 * ] [ nip 8 * ] 2bi
|
[ 1 + - -8 * ] [ nip 8 * ] 2bi
|
||||||
'[ _ shift HEX: ff bitand _ shift ]
|
[ + ] [ nip byte-mask ] 2bi
|
||||||
|
'[ _ shift _ bitand ]
|
||||||
] with map
|
] with map
|
||||||
] [ 1 - [ bitor ] n*quot ] bi
|
] [ 1 - [ bitor ] n*quot ] bi
|
||||||
] [
|
] [
|
||||||
|
|
Loading…
Reference in New Issue