cvs: php4 /ext/standard/ levenshtein.c

From: Date: Tue, 23 May 2000 20:07:32 +0000
Subject: cvs: php4 /ext/standard/ levenshtein.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-15600@lists.php.net to get a copy of this message
hholzgra Tue May 23 22:07:32 2000 EDT Modified files: /php4/ext/standard levenshtein.c Log: a little less optimized, but no dirty tricks anymore Index: php4/ext/standard/levenshtein.c diff -u php4/ext/standard/levenshtein.c:1.4 php4/ext/standard/levenshtein.c:1.5 --- php4/ext/standard/levenshtein.c:1.4 Tue May 23 21:27:02 2000 +++ php4/ext/standard/levenshtein.c Tue May 23 22:07:32 2000 @@ -15,7 +15,7 @@ | Author: Bjørn Borud - Guardian Networks AS <borud@guardian.no> | +----------------------------------------------------------------------+ */ -/* $Id: levenshtein.c,v 1.4 2000/05/23 19:27:02 sas Exp $ */ +/* $Id: levenshtein.c,v 1.5 2000/05/23 20:07:32 hholzgra Exp $ */ #include "php.h" #include <stdlib.h> @@ -25,10 +25,11 @@ static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscated */ { - register char *p1,*p2; + register char *p1,*p2; register int i,j,n; int l1=0,l2=0; char r[512]; + const char *tmp; /* skip equal start sequence, if any */ while(*s1==*s2) { @@ -54,22 +55,15 @@ /* reset pointers, adjust length */ s1-=l1++; s2-=l2++; + /* possible dist to great? */ if(abs(l1-l2)>=255) return -1; /* swap if l2 longer than l1 */ if(l1<l2) { - const char *s3; - int l3; - - s3 = s1; - s1 = s2; - s2 = s3; - - l3 = l1; - l1 = l2; - l2 = l3; + tmp=s1; s1=s2; s2=tmp; + l1 ^= l2; l2 ^= l1; l1 ^= l2; }

« previous php.version4 (#15600) next »