From b1ac83c90896a5a7565590b34e0b5d7e474f9a06 Mon Sep 17 00:00:00 2001 From: John Benediktsson <mrjbq7@gmail.com> Date: Sun, 31 May 2015 07:08:07 -0700 Subject: [PATCH] io.binary.fast: speed up when used by byte-arrays. --- extra/io/binary/fast/fast.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extra/io/binary/fast/fast.factor b/extra/io/binary/fast/fast.factor index c4afd858a1..ce0b483745 100644 --- a/extra/io/binary/fast/fast.factor +++ b/extra/io/binary/fast/fast.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2011 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien.data byte-arrays combinators combinators.smart -endian fry io.binary kernel locals macros math math.ranges +endian fry hints kernel locals macros math math.ranges sequences sequences.generalizations ; QUALIFIED-WITH: alien.c-types c RENAME: be> io.binary => slow-be> @@ -37,8 +37,11 @@ MACRO: reassemble-le ( n -- quot ) le-range reassemble-bytes ; :: n-le> ( bytes n -- x ) bytes n check-length drop n firstn-unsafe n reassemble-le ; inline +HINTS: n-be> { byte-array object } ; +HINTS: n-le> { byte-array object } ; + <PRIVATE -: if-endian ( endian bytes seq -- ) +: if-endian ( endian bytes-quot seq-quot -- ) [ compute-native-endianness = [ dup byte-array? ] [ f ] if