[ENH][FIX] (fulltext) Faster String equality.

Scott A Crosby crosby at qwes.math.cmu.edu
Mon Apr 15 13:19:46 UTC 2002


On Mon, 15 Apr 2002, Henrik Gedenryd wrote:

> Scott A Crosby wrote:
>
> > When working on a larger writeup on fulltext, I realized that having an
> > additional check of:
> >
> > self == aString ifTrue: [^ true].
>
> Just a tiny thing: How about putting this line first?
>

Excellent.. That may be worth a little more. I was primarly concerned with
saving a slow compare.

Scott


> > self == aString ifTrue: [^ true].
> > aString species == String ifFalse: [
> > aString isText ifTrue: [^ self = aString string].
> > ^ false].
> > ^ (self compare: self with: aString collated: AsciiOrder) = 2! !
>
> Should not be worse, may give more speed. So:
>
> = aString
>         "Answer whether the receiver sorts equally as aString.
>         The collation order is simple ascii (with case differences)."
>
>         self == aString ifTrue: [^ true].
>         ^aString species == String
>             ifFalse: [
>                 aString isText and: [self = aString string]].
>            ifTrue: [
>                 (self compare: self with: aString collated: AsciiOrder) = 2]
>
> Henrik
>

--
No DVD movie will ever enter the public domain, nor will any CD. The last CD
and the last DVD will have moldered away decades before they leave copyright.
This is not encouraging the creation of knowledge in the public domain.




More information about the Squeak-dev mailing list