/ Check-in [78e17068]
Login

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

Overview
Comment:Use memmove() rather than a home-made copy loop in dropCell() of btree.c, for a size reduction and performance improvement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 78e1706804e88a0dd5dc40bee838a3a504cfa53b
User & Date: drh 2013-12-09 01:58:11
Context
2013-12-09
02:32
Use memmove() rather than a home-made copy loop in insertCell() too. check-in: a3d796b1 user: drh tags: trunk
01:58
Use memmove() rather than a home-made copy loop in dropCell() of btree.c, for a size reduction and performance improvement. check-in: 78e17068 user: drh tags: trunk
01:04
Avoid unnecessary no-op calls from getAndInitPage() to btreeInitPage() in the btree.c logic. check-in: 81f5ae13 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  5667   5667   **
  5668   5668   ** "sz" must be the number of bytes in the cell.
  5669   5669   */
  5670   5670   static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
  5671   5671     u32 pc;         /* Offset to cell content of cell being deleted */
  5672   5672     u8 *data;       /* pPage->aData */
  5673   5673     u8 *ptr;        /* Used to move bytes around within data[] */
  5674         -  u8 *endPtr;     /* End of loop */
  5675   5674     int rc;         /* The return code */
  5676   5675     int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */
  5677   5676   
  5678   5677     if( *pRC ) return;
  5679   5678   
  5680   5679     assert( idx>=0 && idx<pPage->nCell );
  5681   5680     assert( sz==cellSize(pPage, idx) );
................................................................................
  5692   5691       return;
  5693   5692     }
  5694   5693     rc = freeSpace(pPage, pc, sz);
  5695   5694     if( rc ){
  5696   5695       *pRC = rc;
  5697   5696       return;
  5698   5697     }
  5699         -  endPtr = &pPage->aCellIdx[2*pPage->nCell - 2];
  5700         -  assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 );  /* ptr is always 2-byte aligned */
  5701         -  while( ptr<endPtr ){
  5702         -    *(u16*)ptr = *(u16*)&ptr[2];
  5703         -    ptr += 2;
  5704         -  }
  5705   5698     pPage->nCell--;
         5699  +  memmove(ptr, ptr+2, 2*(pPage->nCell - idx));
  5706   5700     put2byte(&data[hdr+3], pPage->nCell);
  5707   5701     pPage->nFree += 2;
  5708   5702   }
  5709   5703   
  5710   5704   /*
  5711   5705   ** Insert a new cell on pPage at cell index "i".  pCell points to the
  5712   5706   ** content of the cell.