SQLite

Check-in [b25bac7919]
Login

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

Overview
Comment:Update sqlite3MemCompare() to try common cases first, for a modest speed improvement.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b25bac79191975149d88fe34618c74354de62c5e
User & Date: drh 2013-08-21 19:13:53.653
Context
2013-08-21
19:59
Fix typo in test. (check-in: f9859fe93b user: mistachkin tags: trunk)
19:13
Update sqlite3MemCompare() to try common cases first, for a modest speed improvement. (check-in: b25bac7919 user: drh tags: trunk)
17:35
If a virtual table xSync() returns an error message, copy it into a buffer allocated by sqlite3DbMalloc() before transfering it to Vdbe.zErrMsg. (check-in: 854ba30490 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbemem.c.
795
796
797
798
799
800
801

802
803
804
805
806
807
808
809
810


811
812
813
814
815


816
817
818

819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
  }

  /* If one value is a number and the other is not, the number is less.
  ** If both are numbers, compare as reals if one is a real, or as integers
  ** if both values are integers.
  */
  if( combined_flags&(MEM_Int|MEM_Real) ){

    if( !(f1&(MEM_Int|MEM_Real)) ){
      return 1;
    }
    if( !(f2&(MEM_Int|MEM_Real)) ){
      return -1;
    }
    if( (f1 & f2 & MEM_Int)==0 ){
      double r1, r2;
      if( (f1&MEM_Real)==0 ){


        r1 = (double)pMem1->u.i;
      }else{
        r1 = pMem1->r;
      }
      if( (f2&MEM_Real)==0 ){


        r2 = (double)pMem2->u.i;
      }else{
        r2 = pMem2->r;

      }
      if( r1<r2 ) return -1;
      if( r1>r2 ) return 1;
      return 0;
    }else{
      assert( f1&MEM_Int );
      assert( f2&MEM_Int );
      if( pMem1->u.i < pMem2->u.i ) return -1;
      if( pMem1->u.i > pMem2->u.i ) return 1;
      return 0;
    }
  }

  /* If one value is a string and the other is a blob, the string is less.
  ** If both are strings, compare using the collating functions.
  */
  if( combined_flags&MEM_Str ){
    if( (f1 & MEM_Str)==0 ){







>
|
|
<
|
|

<
<
|
>
>
|
|
|
|
|
>
>
|
|
<
>
|
|
|
|
<
<
<
<
<
<
<







795
796
797
798
799
800
801
802
803
804

805
806
807


808
809
810
811
812
813
814
815
816
817
818
819

820
821
822
823
824







825
826
827
828
829
830
831
  }

  /* If one value is a number and the other is not, the number is less.
  ** If both are numbers, compare as reals if one is a real, or as integers
  ** if both values are integers.
  */
  if( combined_flags&(MEM_Int|MEM_Real) ){
    double r1, r2;
    if( (f1 & f2 & MEM_Int)!=0 ){
      if( pMem1->u.i < pMem2->u.i ) return -1;

      if( pMem1->u.i > pMem2->u.i ) return 1;
      return 0;
    }


    if( (f1&MEM_Real)!=0 ){
      r1 = pMem1->r;
    }else if( (f1&MEM_Int)!=0 ){
      r1 = (double)pMem1->u.i;
    }else{
      return 1;
    }
    if( (f2&MEM_Real)!=0 ){
      r2 = pMem2->r;
    }else if( (f2&MEM_Int)!=0 ){
      r2 = (double)pMem2->u.i;
    }else{

      return -1;
    }
    if( r1<r2 ) return -1;
    if( r1>r2 ) return 1;
    return 0;







  }

  /* If one value is a string and the other is a blob, the string is less.
  ** If both are strings, compare using the collating functions.
  */
  if( combined_flags&MEM_Str ){
    if( (f1 & MEM_Str)==0 ){