]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Performance improvement to the sqlite3MemCompare() routine by factoring out
authordrh <drh@noemail.net>
Tue, 16 Sep 2014 03:24:43 +0000 (03:24 +0000)
committerdrh <drh@noemail.net>
Tue, 16 Sep 2014 03:24:43 +0000 (03:24 +0000)
sqlite3BlobCompare().

FossilOrigin-Name: 20ed2321b09ba076e50f9fc2f42c135b25746d72

manifest
manifest.uuid
src/vdbeaux.c

index 44c6f5bfa6878807c704996872c8cdd8bea4b22a..8a0b3a189a0d0f5eb33592efbd8b32cbd9268702 100644 (file)
--- a/manifest
+++ b/manifest
@@ -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
index f4f07abe9e80d3629408e15f68a72f7a5ffa853b..bbfe9273ddd30207457a91eaa7d3d00a14b0fa6c 100644 (file)
@@ -1 +1 @@
-4060efb646c873c4abde7ab9ddf330489a44f274
\ No newline at end of file
+20ed2321b09ba076e50f9fc2f42c135b25746d72
\ No newline at end of file
index a653587319be944c9d585ded70011aae3db24cb0..86f36aba877cc1006344e139143f3a5de752c351 100644 (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);
 }