1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-09-02 12:21:26 +03:00

Performance improvement to the sqlite3MemCompare() routine by factoring out

sqlite3BlobCompare().

FossilOrigin-Name: 20ed2321b09ba076e50f9fc2f42c135b25746d72
This commit is contained in:
drh
2014-09-16 03:24:43 +00:00
parent b6dea49f3d
commit 982ff72f0f
3 changed files with 21 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Fix\stool/showwal.c\sso\sthat\sit\shandles\sWAL\sfiles\sthat\scontain\s64KiB\spages.
D 2014-09-15T16:53:23.593
C Performance\simprovement\sto\sthe\ssqlite3MemCompare()\sroutine\sby\sfactoring\sout\nsqlite3BlobCompare().
D 2014-09-16T03:24:43.248
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -292,7 +292,7 @@ F src/vdbe.c 9a45dcbcc967fc0cb9248c75ba245d1d47de3e78
F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
F src/vdbeInt.h b4843c35c3ba533b69d4250f550b5bacf2fb013d
F src/vdbeapi.c 06b712d4772b318b69cd37a416deb1ff0426aa8c
F src/vdbeaux.c 91fd1e0c54a765838dc61fcf79f31acce035ce38
F src/vdbeaux.c cde99fa6659f5f9000d2d84bb5c4cc85d9e0a200
F src/vdbeblob.c 848238dc73e93e48432991bb5651bf87d865eca4
F src/vdbemem.c dc36ea9fe26c25550c50085f388167086ef7d73a
F src/vdbesort.c a7a40ceca6325b853040ffcc363dcd49a45f201b
@@ -1198,7 +1198,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P dedaa6fb3d2e6e697d4a48649af5f42d9a11c333
R 9c897c2b35082efdf1b1cdba3d9a6e48
U dan
Z fbf2bdf01c7200ebedc4b699448a8435
P 4060efb646c873c4abde7ab9ddf330489a44f274
R 2d14ce03cde1c84220e0226983629fd3
U drh
Z 10220c87d8978c341785bd01c3f5069d

View File

@@ -1 +1 @@
4060efb646c873c4abde7ab9ddf330489a44f274
20ed2321b09ba076e50f9fc2f42c135b25746d72

View File

@@ -3319,6 +3319,18 @@ static int vdbeCompareMemString(
}
}
/*
** Compare two blobs. Return negative, zero, or positive if the first
** is less than, equal to, or greater than the second, respectively.
** If one blob is a prefix of the other, then the shorter is the lessor.
*/
static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
int c = memcmp(pB1->z, pB2->z, pB1->n>pB2->n ? pB2->n : pB1->n);
if( c ) return c;
return pB1->n - pB2->n;
}
/*
** Compare the values contained by the two memory cells, returning
** negative, zero or positive if pMem1 is less than, equal to, or greater
@@ -3329,7 +3341,6 @@ static int vdbeCompareMemString(
** Two NULL values are considered equal by this function.
*/
int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){
int rc;
int f1, f2;
int combined_flags;
@@ -3404,11 +3415,7 @@ int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){
}
/* Both values must be blobs. Compare using memcmp(). */
rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n);
if( rc==0 ){
rc = pMem1->n - pMem2->n;
}
return rc;
return sqlite3BlobCompare(pMem1, pMem2);
}