GHC.Prim.ByteArray# - confusing documentation
Simon Marlow
marlowsd at gmail.com
Wed Dec 30 06:47:13 EST 2009
On 30/12/09 11:09, Bulat Ziganshin wrote:
> Hello Simon,
>
> Wednesday, December 30, 2009, 1:44:54 PM, you wrote:
>
>>> Consequently I expected sizeOfByteArray# to return the same number
>>> that I passed in to newByteArray#. But it doesn't - It returned
>>> however much it decided to allocate, which on my platform is always a
>>> multiple of four bytes.
>>>
>>> This is something which could be clarified in the documentation.
>
>> Thanks, I'll fix the docs.
>
> btw, is it possible to fix the behavior? it will reduce overhead for
> storing small strings
It would be possible yes. When the RTS needs to know the size of the
array in words it would have to do a calculation, so you'd have to find
all the places in the RTS that do this (probably only a handful, as most
of them go through the arr_words_sizeW() inline function).
I don't plan to do this right now. If someone else wants to tackle it
then please go ahead, it'd be a fun afternoon hack.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list