[BUG] equivalence between strings and symbols
Dan Ingalls
Dan.Ingalls at disney.com
Tue Apr 11 23:03:06 UTC 2000
Stephan -
>> > >What about completely *removing* Symbol>>= ?
>> > >
>> > >Has anybody tried this (without changing other methods)?
>>
>> Now, Stephan, the true Squeaker does not ask such a question ;-).
>
>So it seems to be, that I'm not a true Squeaker... ;-).
I wouldn't have teased you if I didn't consider you a consumate Squeaker!
. . .
>> I say "reasonably" because I have not timed anything yet. There can be no doubt that = runs slower than == between large strings. Next time I will time a recompilation of the system before and after -- this should be a good test, since the compiler works fairly heavily with Symbols.
I found a 14% increase in the time, which is surprising, given your results more like 3%:
775090.0 / 677758.0 1.144
Perhaps disk time could is a factor.
But see my later result, below, anyway.
>I have made some benchmarks (Linux, Squeak2.8alpha, update: #1974,
>Morphic), newest first:
>
>Smalltalk garbageCollect.
>[Smalltalk recompileAllFrom: 'Aardvark'.] timeToRun
>"without Transcript"
> 727570 "sr suggestion in ST"
>
> 735792 "without Symbol>>="
> 718127 "with Symbol>>="
> 735708 "without Symbol>>="
> 718915 "with Symbol>>="
>
>My suggestion in ST was:
>
>Symbol = anObject
> (anObject isMemberOf: Symbol)
> ifTrue: [^ self == anObject].
> ^ super = anObject
>
>Regarding performance it is about in the middle between with and without
>ordinary Symbol>>=.
>With a primitive implementation it should be some faster though: but I
>think priority has to rework the code as suggested by Dan below;
>probably a primitive is superfluous then.
Inspired by your suggestion for Symbol =, I improved on it as follows:
Symbol = anObject
self == anObject ifTrue: [^ true]. "Was =="
anObject class == Symbol ifTrue: [^ false]. "Was not =="
^ super = anObject
My timing for this version was...
680991.0 / 677758.0 1.005
...which I consider to be an insignificant degradation. I'm sure one can come up with examples that show more impact, but I think we're down to a reasonable cost for the benefit of symmetry.
Thanks for the challenge.
- Dan
More information about the Squeak-dev
mailing list
|