[squeak-dev] Re: SparseLargeTable
nicolas cellier
ncellier at ifrance.com
Tue Nov 4 00:52:38 UTC 2008
Hmm, you must also define
arrayClass
^arrayClass
otherwise, printString might fail.
nicolas cellier a écrit :
> Eliot Miranda a écrit :
>>
>> Sure this does not really matter, I doubt this access be the
>> bottleneck of any code, and maybe you already hacked primitive 31...
>>
>>
>> No, but if you have, I'm all ears :)
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>
> Hehe, I don't even know the man-hour cost of such a hack...
> The day when identified as a real bottleneck i will have a look.
>
> Concerning SparseLargeTable, I can understand the utility of base as:
> any element of index < base is known to be = defaultValue.
> This should economize some space by reducing basicSize requirement...
> But it does not !
> Browse #new:chunkSize:arrayClass:base:defaultValue:
>
> Also, with base ~= 1, things like #printString become strange:
>
> (SparseLargeTable new: 3 chunkSize: 3 arrayClass: Array base: 2
> defaultValue: -1) printString.
> -> 'a SparseLargeTable(-1 -1)'
>
> Though its size is 3, and:
> | tmp |
> tmp := SparseLargeTable new: 3 chunkSize: 3 arrayClass: Array base: 2
> defaultValue: -1.
> (1 to: 3) collect: [:i | tmp at: i]
> -> #(-1 -1 -1)
>
> Also, in #analyzeSpaceSaving total should be either
> total := size - base + 1.
> or:
> total := size.
> but not:
> total := size - base.
> as you proposed.
>
> 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...
>
> Nicolas
>
>
>
More information about the Squeak-dev
mailing list
|