[squeak-dev] Re: SparseLargeTable

Eliot Miranda eliot.miranda at gmail.com
Wed Nov 5 19:46:10 UTC 2008


On Wed, Nov 5, 2008 at 11:41 AM, nicolas cellier <ncellier at ifrance.com>wrote:

> Eliot Miranda a écrit :
>
>>
>>    Also, lastChunkSize is not set to a correct size.
>>    It should be:
>>           (lastChunkSize := size - base + 1 \\ chunkSize) = 0 ifTrue:
>>                   [lastChunkSize := chunkSize].
>>    which can be more efficiently written:
>>           lastChunkSize := size - base \\ chunkSize + 1.
>>
>>    Well, I guess every one use with base = 1...
>>
>>
>> No that's not right.  base determines the first index, so that e.g.
>>  SparseLargeArray
>> new: (2 raisedToInteger: 32)
>> chunkSize: 32 * 1024
>> arrayClass: ByteArray
>> base: 0
>> defaultValue: 0
>>
>> provides a bye-addressible array of 2^32 elements with indices 0 through
>> (2 raisedTo: 32) - 1.
>>
>>
> That's interesting because that's exactly how I understood 'base' first.
> But that's not how it did work before your patches.
> SparseLargeTable inherits from ArrayedCollection for which the whole
> protocol require indices between 1 and self size...


Can you say which methods require this and why?


> And that is effectively how SparseLargeTable at: and at:put: did handle the
> indices... (mySparseTable at: 0) did not work.
>
> A logical explanation was that base was here for saving bytes, but that was
> only a deduction, i did not discuss that with Yoshiki.
>
> That's also why the (self basicAt: anIndex) were protected in #noChekAt:
> the first elements (before base) and also the last ones (see how
> #zapDefaultOnlyEntries use #privateSize: ) were potentially out of self
> "basicBounds".
>
> Now, the modifications you made are appealing, but beware not using one of
> the 1-based inherited message on self. That's rather not bug-proof.


I'd like to plug those holes. I absolutely need 0-based sparse arrays :)


>
> Nicolas
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20081105/a87f6deb/attachment.htm


More information about the Squeak-dev mailing list