aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-09-16 03:24:43 +0000
committerdrh <drh@noemail.net>2014-09-16 03:24:43 +0000
commit982ff72f0f90e9bc5bc314482e6fba1cc4ca2579 (patch)
treef253eaa5f10f9fa167fecee89fb67a2c144bde76 /src
parentb6dea49f3d30bd348676eb5c6795f6f1ea5c173c (diff)
downloadsqlite-982ff72f0f90e9bc5bc314482e6fba1cc4ca2579.tar.gz
sqlite-982ff72f0f90e9bc5bc314482e6fba1cc4ca2579.zip
Performance improvement to the sqlite3MemCompare() routine by factoring out
sqlite3BlobCompare(). FossilOrigin-Name: 20ed2321b09ba076e50f9fc2f42c135b25746d72
Diffstat (limited to 'src')
-rw-r--r--src/vdbeaux.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index a65358731..86f36aba8 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -3320,6 +3320,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
** than pMem2. Sorting order is NULL's first, followed by numbers (integers
@@ -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);
}