From be5a0993791d665b2002d82133713d86bcb6c24d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 17 Dec 2008 01:40:09 -0600 Subject: [PATCH] refactor some weirdness in checksums.common --- basis/checksums/common/common.factor | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/basis/checksums/common/common.factor b/basis/checksums/common/common.factor index 7d5f34777d..0ae4328446 100644 --- a/basis/checksums/common/common.factor +++ b/basis/checksums/common/common.factor @@ -1,21 +1,20 @@ ! Copyright (C) 2006, 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.bitwise strings io.binary namespaces -make grouping ; +make grouping byte-arrays ; IN: checksums.common SYMBOL: bytes-read -: calculate-pad-length ( length -- pad-length ) - dup 56 < 55 119 ? swap - ; +: calculate-pad-length ( length -- length' ) + [ 56 < 55 119 ? ] keep - ; : pad-last-block ( str big-endian? length -- str ) [ - rot % - HEX: 80 , - dup HEX: 3f bitand calculate-pad-length 0 % - 3 shift 8 rot [ >be ] [ >le ] if % - ] "" make 64 group ; + [ % ] 2dip HEX: 80 , + [ HEX: 3f bitand calculate-pad-length % ] + [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi + ] B{ } make 64 group ; : update-old-new ( old new -- ) [ [ get ] bi@ w+ dup ] 2keep [ set ] bi@ ; inline