[Haskell-cafe] Slower with ByteStrings?

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun May 27 08:50:15 EDT 2007


Hello Bryan,

Sunday, May 27, 2007, 3:30:50 AM, you wrote:
>> I think, given my simple algorithm that means that (==) for
>> ByteStrings is slower than (==) for String.  Is this possible?

> Yes indeed.  Over ByteStrings, (==) is implemented as a call to memcmp.
>   For small strings, this loses by a large margin because it has to go
> through the FFI.

how about using *unsafe* memcmp import and more complex code for the
case of large BS length?

a==b | min (length a) (length b) < 20   = memcmp a b
     ....


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list