[Haskell-cafe] Performance: MD5

Andrew Coppin andrewcoppin at btinternet.com
Sun May 18 08:08:02 EDT 2008


Bulat Ziganshin wrote:
> Hello Andrew,
>
> Sunday, May 18, 2008, 3:42:23 PM, you wrote:
>
>   
>> Isn't there some function kicking around somewhere for acessing arrays
>> without the bounds check? Similarly, I'm sure I remember the Data.Bits
>> bounds check being mentioned before, and somebody saying they had [or 
>> were going to?] make an unsafe variant available. I've looked around the
>> library documentation and I'm not seeing anything... any hints?
>>     
>
> unsafeRead/Write
>   

Found in Data.Array.Base, apparently. (I managed to find an example in 
the Gtk2hs "fastdraw" demo.)

Oddly, this seems to make virtually no performance difference. I find 
this highly surprising. But then, I perform 16 write to the array, and 
64 reads from the ByteString, so maybe that's where I should be worrying 
about bounds checks...

> (I# a) <<# (I# b) = (I# (a `iShiftL#` b))
> (I# a) >># (I# b) = (I# (a `uncheckedIShiftRL#` b))
>   

Does it make a difference if I want Word32 instead of Int?



More information about the Haskell-Cafe mailing list