slight speedup in base64

db4
Doug Coleman 2008-02-10 23:07:40 -06:00
parent fcb49a3442
commit b6cc47d2b3
2 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
USING: tools.test base64 ;
USING: kernel tools.test base64 strings ;
[ "abcdefghijklmnopqrstuvwxyz" ] [ "abcdefghijklmnopqrstuvwxyz" >base64 base64>
] unit-test

View File

@ -35,13 +35,13 @@ PRIVATE>
#! pad string with = when not enough bits
dup length dup 3 mod - cut swap
[
3 group [ encode3 % ] each
3 <groups> [ encode3 % ] each
dup empty? [ drop ] [ >base64-rem % ] if
] "" make ;
: base64> ( base64 -- str )
#! input length must be a multiple of 4
[
[ 4 group [ decode4 % ] each ] keep [ CHAR: = = not ] count-end
[ 4 <groups> [ decode4 % ] each ] keep [ CHAR: = = not ] count-end
] SBUF" " make swap [ dup pop* ] times >string ;