/ Check-in [9cd30d33]
Login

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

Overview
Comment:Avoid unnecessary calls to sqlite3VdbeSerialTypeLen() for integer serial types, for a small size reduction and a speed increase.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9cd30d33b1d02dc8c55c1d74bdbcefab63ebf2a7
User & Date: drh 2015-06-28 02:58:51
Context
2015-06-28
17:33
Comment typo fix and minor cleanup in the pager. No logic changes. check-in: 94ef1701 user: drh tags: trunk
02:58
Avoid unnecessary calls to sqlite3VdbeSerialTypeLen() for integer serial types, for a small size reduction and a speed increase. check-in: 9cd30d33 user: drh tags: trunk
2015-06-27
23:55
Make greater use of BtCursor.curIntKey. check-in: 63998471 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  2957   2957     n = (u32)pMem->n;
  2958   2958     if( flags & MEM_Zero ){
  2959   2959       n += pMem->u.nZero;
  2960   2960     }
  2961   2961     return ((n*2) + 12 + ((flags&MEM_Str)!=0));
  2962   2962   }
  2963   2963   
         2964  +/*
         2965  +** The sizes for serial types less than 12
         2966  +*/
         2967  +static const u8 sqlite3SmallTypeSizes[] = {
         2968  +  0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0
         2969  +};
         2970  +
  2964   2971   /*
  2965   2972   ** Return the length of the data corresponding to the supplied serial-type.
  2966   2973   */
  2967   2974   u32 sqlite3VdbeSerialTypeLen(u32 serial_type){
  2968   2975     if( serial_type>=12 ){
  2969   2976       return (serial_type-12)/2;
  2970   2977     }else{
  2971         -    static const u8 aSize[] = { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 };
  2972         -    return aSize[serial_type];
         2978  +    return sqlite3SmallTypeSizes[serial_type];
  2973   2979     }
  2974   2980   }
  2975   2981   
  2976   2982   /*
  2977   2983   ** If we are on an architecture with mixed-endian floating 
  2978   2984   ** points (ex: ARM7) then swap the lower 4 bytes with the 
  2979   2985   ** upper 4 bytes.  Return the result.
................................................................................
  3049   3055       if( serial_type==7 ){
  3050   3056         assert( sizeof(v)==sizeof(pMem->u.r) );
  3051   3057         memcpy(&v, &pMem->u.r, sizeof(v));
  3052   3058         swapMixedEndianFloat(v);
  3053   3059       }else{
  3054   3060         v = pMem->u.i;
  3055   3061       }
  3056         -    len = i = sqlite3VdbeSerialTypeLen(serial_type);
         3062  +    len = i = sqlite3SmallTypeSizes[serial_type];
  3057   3063       assert( i>0 );
  3058   3064       do{
  3059   3065         buf[--i] = (u8)(v&0xFF);
  3060   3066         v >>= 8;
  3061   3067       }while( i );
  3062   3068       return len;
  3063   3069     }
................................................................................
  4078   4084     testcase( typeRowid==5 );
  4079   4085     testcase( typeRowid==6 );
  4080   4086     testcase( typeRowid==8 );
  4081   4087     testcase( typeRowid==9 );
  4082   4088     if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){
  4083   4089       goto idx_rowid_corruption;
  4084   4090     }
  4085         -  lenRowid = sqlite3VdbeSerialTypeLen(typeRowid);
         4091  +  lenRowid = sqlite3SmallTypeSizes[typeRowid];
  4086   4092     testcase( (u32)m.n==szHdr+lenRowid );
  4087   4093     if( unlikely((u32)m.n<szHdr+lenRowid) ){
  4088   4094       goto idx_rowid_corruption;
  4089   4095     }
  4090   4096   
  4091   4097     /* Fetch the integer off the end of the index record */
  4092   4098     sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);