Re: [Pharo-project] IdentitySet but using #hash rather than #identityHash ?
On 16.12.2011 01:06, Henrik Sperre Johansen wrote:
Usual identitySet: n := 1000000. set := IdentitySet new: n. Time millisecondsToRun: [1 to: n do: [:waste | set add: Object new.]] 4595
Custom subclass with a slightly modified hash (anObject identityHash + (anObject class basicIdentityHash bitShift: 6)): n := 1000000. set := PseudoIdentitySet2 new: n. Time millisecondsToRun: [1 to: n do: [:waste | set add: Object new.]] 3694 Why 6 you ask? Because I'm worth it.
Not really enough to justify the extra compexity, imho.
Cheers, Henry
To put that a bit more in perspective, the extra cost for not preallocating to a sane value: n := 1000000. set := IdentitySet new. Time millisecondsToRun: [1 to: n do: [:waste | set add: Object new.]] 6872 Cheers, Henry
participants (1)
-
Henrik Sperre Johansen