On Wed, Apr 10, 2019 at 10:42 AM Stéphane Ducasse
<stephane.duca...@inria.fr> wrote:
>
> 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?

Hi,

I think Sophie already did most of the work to introduce a new
primitive. The missing steps to use the new optimized way to compare
strings are:
- Add the primitive to the primitive table VM side for Pharo/Squeak and Newspeak
- Use the new primitive in the image and call this one for string comparison

With this new primitive performances on string comparison can be
improved around x2.5 to x5 times faster.

>
> 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
>


-- 
Cyril Ferlicot
https://ferlicot.fr

Reply via email to