Hi 

I recall that clement told me that returning 1,2 or 3 instead of negative, 
zero, positive was slow.
And I wonder if the primitive got change to the logic clement proposed?

Could we not introduce another primitive and use it from the image?

compare: string1 with: string2 collated: order
        "Return 1, 2 or 3, if string1 is <, =, or > string2, with the collating 
order of characters given by the order array."

        | len1 len2 c1 c2 |
        <primitive: 'primitiveCompareString' module: 'MiscPrimitivePlugin'>
        
        <var: #string1 declareC: 'unsigned char *string1'>
        <var: #string2 declareC: 'unsigned char *string2'>
        <var: #order declareC: 'unsigned char *order'>

        len1 := string1 size.
        len2 := string2 size.
        1 to: (len1 min: len2) do:
                [:i |
                c1 := order at: (string1 basicAt: i) + 1.
                c2 := order at: (string2 basicAt: i) + 1.
                c1 = c2 ifFalse: 
                        [c1 < c2 ifTrue: [^ 1] ifFalse: [^ 3]]].
        len1 = len2 ifTrue: [^ 2].
        len1 < len2 ifTrue: [^ 1] ifFalse: [^ 3].

--------------------------------------------
Stéphane Ducasse
http://stephane.ducasse.free.fr
http://www.synectique.eu / http://www.pharo.org 
03 59 35 87 52
Assistant: Julie Jonas 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
Villeneuve d'Ascq 59650
France

Reply via email to