On 05.10.2011 11:19, Henrik Sperre Johansen wrote:
On 05.10.2011 01:59, Nicolas Cellier wrote:
However, maybe Mariano is searching for tight inner loop optimization (we can only guess, because he didn't tell, he should have). In this case, using ifFalse: is good: because it is inlined by Compiler, it avoids a BlockClosure creation. But above code will cost two lookup in both branch, so it will be pretty bad too, depending on hash evaluation cost and collision rate, in a majority of cases, worse than block creation time.
You could make at:ifAbsentPut: do single lookup, at the cost of using cull: (with the scanned for index) in at:ifAbsent: . Sort of restricts what you can pass to at:ifAbsent: though, (not that I found any not using a block in a quick scan of senders, nor did my image crash) and the runtime really didn't improve that much. Here's the .cs for those interested, btw.
Cheers, Henry