diff --git a/extra/io/binary/fast/fast.factor b/extra/io/binary/fast/fast.factor index 07ab1766d4..4773434608 100644 --- a/extra/io/binary/fast/fast.factor +++ b/extra/io/binary/fast/fast.factor @@ -3,6 +3,8 @@ USING: combinators combinators.smart fry kernel macros math math.ranges sequences sequences.generalizations io.binary locals ; +RENAME: be> io.binary => slow-be> +RENAME: le> io.binary => slow-le> IN: io.binary.fast ERROR: bad-length bytes n ; @@ -36,7 +38,22 @@ MACRO: reassemble-le ( n -- quot ) le-range reassemble-bytes ; : 4be> ( bytes -- x ) 4 n-be> ; : 8be> ( bytes -- x ) 8 n-be> ; +: be> ( bytes -- x ) + dup length { + { 2 [ 2be> ] } + { 4 [ 4be> ] } + { 8 [ 8be> ] } + [ drop slow-be> ] + } case ; + : 2le> ( bytes -- x ) 2 n-le> ; : 4le> ( bytes -- x ) 4 n-le> ; : 8le> ( bytes -- x ) 8 n-le> ; +: le> ( bytes -- x ) + dup length { + { 2 [ 2le> ] } + { 4 [ 4le> ] } + { 8 [ 8le> ] } + [ drop slow-le> ] + } case ;