/ Check-in [20ed2321]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Performance improvement to the sqlite3MemCompare() routine by factoring out sqlite3BlobCompare().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 20ed2321b09ba076e50f9fc2f42c135b25746d72
User & Date: drh 2014-09-16 03:24:43
Context
2014-09-16
13:30
Changes to sqlite3VdbeRecordUnpack() to make it slightly smaller and faster. check-in: 8fb90da7 user: drh tags: trunk
03:24
Performance improvement to the sqlite3MemCompare() routine by factoring out sqlite3BlobCompare(). check-in: 20ed2321 user: drh tags: trunk
2014-09-15
16:53
Fix tool/showwal.c so that it handles WAL files that contain 64KiB pages. check-in: 4060efb6 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  3314   3314       rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
  3315   3315       sqlite3VdbeMemRelease(&c1);
  3316   3316       sqlite3VdbeMemRelease(&c2);
  3317   3317       if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM;
  3318   3318       return rc;
  3319   3319     }
  3320   3320   }
         3321  +
         3322  +/*
         3323  +** Compare two blobs.  Return negative, zero, or positive if the first
         3324  +** is less than, equal to, or greater than the second, respectively.
         3325  +** If one blob is a prefix of the other, then the shorter is the lessor.
         3326  +*/
         3327  +static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
         3328  +  int c = memcmp(pB1->z, pB2->z, pB1->n>pB2->n ? pB2->n : pB1->n);
         3329  +  if( c ) return c;
         3330  +  return pB1->n - pB2->n;
         3331  +}
         3332  +
  3321   3333   
  3322   3334   /*
  3323   3335   ** Compare the values contained by the two memory cells, returning
  3324   3336   ** negative, zero or positive if pMem1 is less than, equal to, or greater
  3325   3337   ** than pMem2. Sorting order is NULL's first, followed by numbers (integers
  3326   3338   ** and reals) sorted numerically, followed by text ordered by the collating
  3327   3339   ** sequence pColl and finally blob's ordered by memcmp().
  3328   3340   **
  3329   3341   ** Two NULL values are considered equal by this function.
  3330   3342   */
  3331   3343   int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){
  3332         -  int rc;
  3333   3344     int f1, f2;
  3334   3345     int combined_flags;
  3335   3346   
  3336   3347     f1 = pMem1->flags;
  3337   3348     f2 = pMem2->flags;
  3338   3349     combined_flags = f1|f2;
  3339   3350     assert( (combined_flags & MEM_RowSet)==0 );
................................................................................
  3400   3411         return vdbeCompareMemString(pMem1, pMem2, pColl, 0);
  3401   3412       }
  3402   3413       /* If a NULL pointer was passed as the collate function, fall through
  3403   3414       ** to the blob case and use memcmp().  */
  3404   3415     }
  3405   3416    
  3406   3417     /* Both values must be blobs.  Compare using memcmp().  */
  3407         -  rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n);
  3408         -  if( rc==0 ){
  3409         -    rc = pMem1->n - pMem2->n;
  3410         -  }
  3411         -  return rc;
         3418  +  return sqlite3BlobCompare(pMem1, pMem2);
  3412   3419   }
  3413   3420   
  3414   3421   
  3415   3422   /*
  3416   3423   ** The first argument passed to this function is a serial-type that
  3417   3424   ** corresponds to an integer - all values between 1 and 9 inclusive 
  3418   3425   ** except 7. The second points to a buffer containing an integer value