1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-09-11 08:30:57 +03:00

Reduce the number of arguments to RecordCompare functions from 4 to 3,

resulting in a small performance increase.

FossilOrigin-Name: 8239c35aedd583af79505378bb7dbb78346a3f45
This commit is contained in:
drh
2014-09-16 14:37:35 +00:00
parent 035e563bf6
commit 75179ded97
7 changed files with 37 additions and 37 deletions

View File

@@ -3482,7 +3482,7 @@ static i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){
** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the
** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).
*/
int sqlite3VdbeRecordCompare(
static int vdbeRecordCompareWithSkip(
int nKey1, const void *pKey1, /* Left key */
UnpackedRecord *pPKey2, /* Right key */
int bSkip /* If true, skip the first field */
@@ -3664,6 +3664,13 @@ int sqlite3VdbeRecordCompare(
);
return pPKey2->default_rc;
}
int sqlite3VdbeRecordCompare(
int nKey1, const void *pKey1, /* Left key */
UnpackedRecord *pPKey2 /* Right key */
){
return vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
}
/*
** This function is an optimized version of sqlite3VdbeRecordCompare()
@@ -3676,8 +3683,7 @@ int sqlite3VdbeRecordCompare(
*/
static int vdbeRecordCompareInt(
int nKey1, const void *pKey1, /* Left key */
UnpackedRecord *pPKey2, /* Right key */
int bSkip /* Ignored */
UnpackedRecord *pPKey2 /* Right key */
){
const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F];
int serial_type = ((const u8*)pKey1)[1];
@@ -3686,9 +3692,7 @@ static int vdbeRecordCompareInt(
u64 x;
i64 v = pPKey2->aMem[0].u.i;
i64 lhs;
UNUSED_PARAMETER(bSkip);
assert( bSkip==0 );
assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );
switch( serial_type ){
case 1: { /* 1-byte signed integer */
@@ -3738,10 +3742,10 @@ static int vdbeRecordCompareInt(
** (as gcc is clever enough to combine the two like cases). Other
** compilers might be similar. */
case 0: case 7:
return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2, 0);
return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);
default:
return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2, 0);
return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);
}
if( v>lhs ){
@@ -3751,7 +3755,7 @@ static int vdbeRecordCompareInt(
}else if( pPKey2->nField>1 ){
/* The first fields of the two keys are equal. Compare the trailing
** fields. */
res = sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2, 1);
res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
}else{
/* The first fields of the two keys are equal and there are no trailing
** fields. Return pPKey2->default_rc in this case. */
@@ -3770,17 +3774,13 @@ static int vdbeRecordCompareInt(
*/
static int vdbeRecordCompareString(
int nKey1, const void *pKey1, /* Left key */
UnpackedRecord *pPKey2, /* Right key */
int bSkip
UnpackedRecord *pPKey2 /* Right key */
){
const u8 *aKey1 = (const u8*)pKey1;
int serial_type;
int res;
UNUSED_PARAMETER(bSkip);
assert( bSkip==0 );
getVarint32(&aKey1[1], serial_type);
if( serial_type<12 ){
res = pPKey2->r1; /* (pKey1/nKey1) is a number or a null */
}else if( !(serial_type & 0x01) ){
@@ -3802,7 +3802,7 @@ static int vdbeRecordCompareString(
res = nStr - pPKey2->aMem[0].n;
if( res==0 ){
if( pPKey2->nField>1 ){
res = sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2, 1);
res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
}else{
res = pPKey2->default_rc;
}
@@ -3980,7 +3980,7 @@ int sqlite3VdbeIdxKeyCompare(
if( rc ){
return rc;
}
*res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked, 0);
*res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);
sqlite3VdbeMemRelease(&m);
return SQLITE_OK;
}