[TIP] Case-sensitive string comparison in 4D v11

Jeffrey Kain (11/18/08 11:35AM)
Bruno LEGAY (11/18/08 6:13PM)
arnaud (11/18/08 6:22PM)
J?r?me Pupier (11/18/08 6:41PM)


Jeffrey Kain (11/18/08 11:35 AM)

<EB8EBE254C16534D9BC41A91DAECF87804BB0946@...

Nope - just guessing that 4D's C code will be faster than 4D code. But

you know what guessing means - it makes a gue out of ss and ing.

-----Original Message-----

From: Doug Cottrill

Sent: Tuesday, November 18, 2008 11:31 AM

Thanks, I like it!

Have you compared this method to doing a manual

string compare?  I'm wondering if the replace string

command is actually any faster than a manual compare

since the replace should need to do the same type of

comparison.  Really of academic interest only to me right

now- just curious.

Bruno LEGAY (11/18/08 6:13 PM)

Hi,

I also use a new v11 feature to do this...

Let me know what you think ?

Code is in french but comments are in english :-)

C_BOOLEEN($0)

C_TEXTE($1)

C_TEXTE($2)

C_BOOLEEN($vb_isEqualStrict)

C_TEXTE($vt_text1)

C_TEXTE($vt_text2)

$vb_isEqualStrict:=Faux

Si (Nombre de parametres>1)

$vt_text1:=$1

$vt_text2:=$2



C_ENTIER LONG($vl_length)

$vl_length:=Longueur($vt_text1)



 `v11 way :-)



Au cas ou

: ($vl_length#Longueur($vt_text2))

 `If the two string are not of the
same length

 `no need to look further



: ($vl_length=0)

 `two empty strings are equal

$vb_isEqualStrict:=Vrai



Sinon

 `we use v11 new diacritic-sensitive
option for Position

 `if the result = 1 (and we know the
strings are of same length)

 `then the strings are strictly equal

$vb_isEqualStrict:=(Position($vt_text1;$vt_text2;1;*)=1)

Fin de cas



Fin de si

$0:=$vb_isEqualStrict

arnaud (11/18/08 6:22 PM)

Le 18 nov. 08 &yacute; 17:35, Jeffrey Kain a &Egrave;crit :

Nope - just guessing that 4D's C code will be faster than 4D code. But

you know what guessing means - it makes a gue out of ss and ing.

I tried, it is really faster than old comparison, interpreted or  

compiled. Difference grows with chain lenght (wow with long chains).

Thanks!

--

Arnaud de Montard

J?r?me Pupier (11/18/08 6:41 PM)

<dc58f4860811180941s7f621852xc7af54771099021b@...

I thought this was clever..

I think it is, even if someone will say..

Yes but,...

;o)

Amicalement,

JÃ&copy;rôme

----------------------------------------------

Let the rhino keep its horn

- Jul 7,2006

West Africa's version of the black rhino appears

to be extinct, the World Conservation Union

said on Friday. (Reuters)

http://www.worldcommunitygrid.org/  : 4D DevTeam

Reply to this message

Summary created 11/18/08 at 8:13PM by Intellex Corporation

Comments welcome at: feedback@intellexcorp.com