diff options
author | drh <drh@noemail.net> | 2018-02-14 20:58:36 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-02-14 20:58:36 +0000 |
commit | d9274a8ae35a5f195a5d4a3629ea74978e69cf13 (patch) | |
tree | fbaf3da807c1c8ea5d8f385ccb2c1a1627644631 | |
parent | 0fae06fcb6bb4d0e0f75d83759fcc0699a533e9a (diff) | |
download | sqlite-d9274a8ae35a5f195a5d4a3629ea74978e69cf13.tar.gz sqlite-d9274a8ae35a5f195a5d4a3629ea74978e69cf13.zip |
Performance optimizations to the editdist3() function in the spellfix
extension.
FossilOrigin-Name: 70d304dcbac4c3fd5e3b96108bffea2ce6c0db19c847397d5c5e268bb90a981d
-rw-r--r-- | ext/misc/spellfix.c | 14 | ||||
-rw-r--r-- | manifest | 12 | ||||
-rw-r--r-- | manifest.uuid | 2 |
3 files changed, 13 insertions, 15 deletions
diff --git a/ext/misc/spellfix.c b/ext/misc/spellfix.c index 1966d554e..28374b8cc 100644 --- a/ext/misc/spellfix.c +++ b/ext/misc/spellfix.c @@ -691,6 +691,7 @@ static int editDist3ConfigLoad( assert( zTo!=0 || nTo==0 ); if( nFrom>100 || nTo>100 ) continue; if( iCost<0 ) continue; + if( iCost>10000 ) continue; /* Costs above 10K are considered infinite */ if( pLang==0 || iLang!=iLangPrev ){ EditDist3Lang *pNew; pNew = sqlite3_realloc64(p->a, (p->nLang+1)*sizeof(p->a[0])); @@ -782,7 +783,7 @@ static int matchFromTo( ){ int b1 = pStr->a[n1].nByte; if( b1>n2 ) return 0; - if( memcmp(pStr->z+n1, z2, b1)!=0 ) return 0; + if( strncmp(pStr->z+n1, z2, b1)!=0 ) return 0; return 1; } @@ -864,9 +865,6 @@ static EditDist3FromString *editDist3FromStringNew( /* ** Update entry m[i] such that it is the minimum of its current value ** and m[j]+iCost. -** -** If the iCost is 1,000,000 or greater, then consider the cost to be -** infinite and skip the update. */ static void updateCost( unsigned int *m, @@ -874,11 +872,11 @@ static void updateCost( int j, int iCost ){ + unsigned int b; assert( iCost>=0 ); - if( iCost<10000 ){ - unsigned int b = m[j] + iCost; - if( b<m[i] ) m[i] = b; - } + assert( iCost<10000 ); + b = m[j] + iCost; + if( b<m[i] ) m[i] = b; } /* @@ -1,5 +1,5 @@ -C Disable\sassert()\sin\sthe\sspellfix\sextension\sif\snot\scompiled\swith\sSQLITE_DEBUG. -D 2018-02-14T20:25:33.844 +C Performance\soptimizations\sto\sthe\seditdist3()\sfunction\sin\sthe\sspellfix\nextension. +D 2018-02-14T20:58:36.311 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea @@ -294,7 +294,7 @@ F ext/misc/series.c f3c0dba5c5c749ce1782b53076108f87cf0b71041eb6023f727a9c50681d F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56 F ext/misc/shathree.c 9e960ba50483214c6a7a4b1517f8d8cef799e9db381195178c3fd3ad207e10c0 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 -F ext/misc/spellfix.c bb73be37491fd5007efab8dfd8ac416315d47f8aba99179b8adb4255e85c7ff5 +F ext/misc/spellfix.c fcf23b0746bfefbec46a54cfb2cd0720c442a6e382247b4049748f882ad26b94 F ext/misc/sqlar.c 57d5bc45cd5492208e451f697404be88f8612527d64c9d42f96b325b64983d74 F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 @@ -1706,7 +1706,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2d3f1f22d53034576a0ec8d9c360fb19efbb05b2e95ad1b09d120fb1b7da33fd -R 4aff58b3b0f19d8824c9d78629ce8a88 +P 3c53ee0fdea4cbf2590e2b289b021b0ef8b7ead2945db1bdfc767432d9447acb +R 52a6749d61b6207535a693308aa98655 U drh -Z bdffc86a194b9f42419156834dd68b1f +Z c6d9011f82c1274dfef70231bb03befb diff --git a/manifest.uuid b/manifest.uuid index 129d55397..8a40d27ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c53ee0fdea4cbf2590e2b289b021b0ef8b7ead2945db1bdfc767432d9447acb
\ No newline at end of file +70d304dcbac4c3fd5e3b96108bffea2ce6c0db19c847397d5c5e268bb90a981d
\ No newline at end of file |