/ Check-in [757668bd]
Login

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

Overview
Comment:make it a little faster (CVS 160)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:757668bd641134a6f7479c8df1c8b06a24d51ee4
User & Date: drh 2000-10-19 14:42:05
Context
2000-10-19
14:59
remove the Et_AppInit() function from tclsqlite (CVS 161) check-in: 8eee1530 user: drh tags: trunk
14:42
make it a little faster (CVS 160) check-in: 757668bd user: drh tags: trunk
14:21
add the sqlite_test_prefixes control file (CVS 159) check-in: 4ccd9103 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
543
544
545
546
547
548
549


550
551
552
553
554
555
556
557
558

559
560
561
562
563
564

565
566
567
568
569
570
571
572
...
618
619
620
621
622
623
624


625













626
627
628
629
630
631
632
633

634
635
636
637
638
639
640
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.44 2000/10/19 01:49:03 drh Exp $
*/
#include "sqliteInt.h"
#include <unistd.h>
#include <ctype.h>

/*
** SQL is translated into a sequence of instructions to be
................................................................................
** already.  Return non-zero if we run out of memory.
**
** NULLs are converted into an empty string.
*/
#define Stringify(P,I) \
   ((P->aStack[I].flags & STK_Str)==0 ? hardStringify(P,I) : 0)
static int hardStringify(Vdbe *p, int i){


  char zBuf[30];
  int fg = p->aStack[i].flags;
  if( fg & STK_Real ){
    sprintf(zBuf,"%.15g",p->aStack[i].r);
  }else if( fg & STK_Int ){
    sprintf(zBuf,"%d",p->aStack[i].i);
  }else{
    p->zStack[i] = "";
    p->aStack[i].n = 1;

    p->aStack[i].flags |= STK_Str;
    return 0;
  }
  p->zStack[i] = sqliteStrDup(zBuf);
  if( p->zStack[i]==0 ) return 1;
  p->aStack[i].n = strlen(p->zStack[i])+1;

  p->aStack[i].flags |= STK_Str|STK_Dyn;
  return 0;
}

/*
** Release the memory associated with the given stack level
*/
#define Release(P,I)  if((P)->aStack[I].flags&STK_Dyn){ hardRelease(P,I); }
................................................................................
}

/*
** Pop the stack N times.  Free any memory associated with the
** popped stack elements.
*/
static void PopStack(Vdbe *p, int N){


  if( p->zStack==0 ) return;













  while( p->tos>=0 && N-->0 ){
    int i = p->tos--;
    if( p->aStack[i].flags & STK_Dyn ){
      sqliteFree(p->zStack[i]);
    }
    p->aStack[i].flags = 0;
    p->zStack[i] = 0;
  }    

}

/*
** Make sure space has been allocated to hold at least N
** stack elements.  Allocate additional stack space if
** necessary.
**







|







 







>
>

|

|

|


<
>
|


|
|
<
>
|







 







>
>

>
>
>
>
>
>
>
>
>
>
>
>
>







|
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559

560
561
562
563
564
565

566
567
568
569
570
571
572
573
574
...
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.45 2000/10/19 14:42:05 drh Exp $
*/
#include "sqliteInt.h"
#include <unistd.h>
#include <ctype.h>

/*
** SQL is translated into a sequence of instructions to be
................................................................................
** already.  Return non-zero if we run out of memory.
**
** NULLs are converted into an empty string.
*/
#define Stringify(P,I) \
   ((P->aStack[I].flags & STK_Str)==0 ? hardStringify(P,I) : 0)
static int hardStringify(Vdbe *p, int i){
  Stack *pStack = &p->aStack[i];
  char **pzStack = &p->zStack[i];
  char zBuf[30];
  int fg = pStack->flags;
  if( fg & STK_Real ){
    sprintf(zBuf,"%.15g",pStack->r);
  }else if( fg & STK_Int ){
    sprintf(zBuf,"%d",pStack->i);
  }else{
    p->zStack[i] = "";

    pStack->n = 1;
    pStack->flags |= STK_Str;
    return 0;
  }
  *pzStack = sqliteStrDup(zBuf);
  if( *pzStack==0 ) return 1;

  pStack->n = strlen(*pzStack)+1;
  pStack->flags |= STK_Str|STK_Dyn;
  return 0;
}

/*
** Release the memory associated with the given stack level
*/
#define Release(P,I)  if((P)->aStack[I].flags&STK_Dyn){ hardRelease(P,I); }
................................................................................
}

/*
** Pop the stack N times.  Free any memory associated with the
** popped stack elements.
*/
static void PopStack(Vdbe *p, int N){
  char **pzStack;
  Stack *pStack;
  if( p->zStack==0 ) return;
  pStack = &p->aStack[p->tos];
  pzStack = &p->zStack[p->tos];
  p->tos -= N;
  while( N-- > 0 ){
    if( pStack->flags & STK_Dyn ){
      sqliteFree(*pzStack);
    }
    pStack->flags = 0;
    *pzStack = 0;
    pStack--;
    pzStack--;
  }
#if 0  /* Older code was a little slower */
  while( p->tos>=0 && N-->0 ){
    int i = p->tos--;
    if( p->aStack[i].flags & STK_Dyn ){
      sqliteFree(p->zStack[i]);
    }
    p->aStack[i].flags = 0;
    p->zStack[i] = 0;
  }
#endif  
}

/*
** Make sure space has been allocated to hold at least N
** stack elements.  Allocate additional stack space if
** necessary.
**