[ENH] BehaviorHashEnh: hash again...
sr at evolgo.de
sr at evolgo.de
Tue Jun 22 06:40:50 UTC 2004
"Change Set: BehaviorHashEnh
Date: 22 June 2004
Author: Stephan Rudlof
Improves the default Object>>hash for Behaviors by installing
Behavior>>hash. String>>hash has been changed a little to avoid infinite
recursion (without changing its semantics).
All is done in the postscript.
Rationale: Object>>hash calling ProtoObject>>identityHash gives poor
results for Behaviors. Therefore a new Behavior>>hash using Symbol>>hash
or String>>hash (the latter slightly changed to avoide infinite
recursion) will be installed.
Consequences:
- It speeds up Set/Dictionary operations with Behaviors a lot (see
below).
- The main consequence for other objects as Behaviors seems to be a
changed hash if they use
self species hash
as a start value for computing their hash.
But AFAICS this doesn't hurt, since in most cases (non meta classes as
species) it maps to Symbol>>hash, which is fast.
Test:
doIt
| allClasses allClassesSet block |
allClasses := Smalltalk allClasses.
block _ [allClassesSet _ allClasses asSet.
[allClasses do: [:class | allClassesSet remove: class]] timeToRun].
{block value. block value. block value}
before and after filing in this cs.
To see the problem again just doIt
| allClasses allClassesSet block |
allClasses := Smalltalk allClasses.
block _ [allClassesSet _ allClasses asIdentitySet.
[allClasses do: [:class | allClassesSet remove: class]] timeToRun].
{block value. block value. block value}.
Future: Best would probably be a better identityHash with more bits
(possibly in V4?).
PS: I've been stumbled over BrowserEnvironmentTest>>testAllClassesDo,
which is dog slow without this cs."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BehaviorHashEnh.cs.gz
Type: application/octet-stream
Size: 1084 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040622/4dcffa9d/BehaviorHashEnh.cs.obj
More information about the Squeak-dev
mailing list
|