]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplify the sqlite3BtreeKeyFetch() and sqlite3BtreeDataFetch() interfaces
authordrh <drh@noemail.net>
Mon, 9 Dec 2013 20:43:22 +0000 (20:43 +0000)
committerdrh <drh@noemail.net>
Mon, 9 Dec 2013 20:43:22 +0000 (20:43 +0000)
to the storage engine.

FossilOrigin-Name: bf97598592ff60fab2a06d8b31b0201200b91684

manifest
manifest.uuid
src/btree.c

index 9713b269fbb8610f49eef4b480fb11480fafe978..63d41eac58006cec93e11cf46f71a98de426ed82 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\sperformance\soptimizations\sin\spager.c.
-D 2013-12-09T19:25:28.392
+C Simplify\sthe\ssqlite3BtreeKeyFetch()\sand\ssqlite3BtreeDataFetch()\sinterfaces\nto\sthe\sstorage\sengine.
+D 2013-12-09T20:43:22.965
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c 1809a7caa2504233bdddd12f5018422421789537
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c 44a44aa21ee24763ddda98d9a41bd85498359ae2
+F src/btree.c 09285d6ffe7d819b9656ea9b7ecf1ab949a926fb
 F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9
 F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
 F src/build.c 47ef8209e56d840d2b35b8a243c6ee567ad52bda
@@ -1146,7 +1146,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 9227ad48e1612b32a3a3e9551c49890f93abc0a7
-R 2aecb7bab925cdbd0159d9e849c7e955
+P ba9eef5f5293633d1479e1d877bf338edb2a9471
+R 11cbe9b8d7b59f7bcb32cf4280072bce
 U drh
-Z 455daaba8769a2d87fdc74aa6d107f2c
+Z c873c3f777f880d8ffd5cf3f18630860
index c5695949d4b9006a48c193bd7084c13b815788fb..4b979d210edfb9b8be5f2c2da1a0ec7a9aef325c 100644 (file)
@@ -1 +1 @@
-ba9eef5f5293633d1479e1d877bf338edb2a9471
\ No newline at end of file
+bf97598592ff60fab2a06d8b31b0201200b91684
\ No newline at end of file
index a03737701ee2852b5da4f8f09232edd80c3ce6b8..da1b91940d552cf91246ecf90b6ad13c1f01e341 100644 (file)
@@ -4192,10 +4192,10 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
 /*
 ** Return a pointer to payload information from the entry that the 
 ** pCur cursor is pointing to.  The pointer is to the beginning of
-** the key if skipKey==0 and it points to the beginning of data if
-** skipKey==1.  The number of bytes of available key/data is written
-** into *pAmt.  If *pAmt==0, then the value returned will not be
-** a valid pointer.
+** the key if index btrees (pPage->intKey==0) and is the data for
+** table btrees (pPage->intKey==1). The number of bytes of available
+** key/data is written into *pAmt.  If *pAmt==0, then the value
+** returned will not be a valid pointer.
 **
 ** This routine is an optimization.  It is common for the entire key
 ** and data to fit on the local page and for there to be no overflow
@@ -4208,41 +4208,21 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
 ** page of the database.  The data might change or move the next time
 ** any btree routine is called.
 */
-static const unsigned char *fetchPayload(
+static const void *fetchPayload(
   BtCursor *pCur,      /* Cursor pointing to entry to read from */
-  u32 *pAmt,           /* Write the number of available bytes here */
-  int skipKey          /* read beginning at data if this is true */
+  u32 *pAmt            /* Write the number of available bytes here */
 ){
-  unsigned char *aPayload;
-  MemPage *pPage;
-  u32 nKey;
-  u32 nLocal;
-
   assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
   assert( pCur->eState==CURSOR_VALID );
+  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
   assert( cursorHoldsMutex(pCur) );
-  pPage = pCur->apPage[pCur->iPage];
-  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
+  assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
   if( pCur->info.nSize==0 ){
     btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
                    &pCur->info);
   }
-  aPayload = pCur->info.pCell;
-  aPayload += pCur->info.nHeader;
-  if( pPage->intKey ){
-    nKey = 0;
-  }else{
-    nKey = (int)pCur->info.nKey;
-  }
-  if( skipKey ){
-    aPayload += nKey;
-    nLocal = pCur->info.nLocal - nKey;
-  }else{
-    nLocal = pCur->info.nLocal;
-    assert( nLocal<=nKey );
-  }
-  *pAmt = nLocal;
-  return aPayload;
+  *pAmt = pCur->info.nLocal;
+  return (void*)(pCur->info.pCell + pCur->info.nHeader);
 }
 
 
@@ -4261,22 +4241,10 @@ static const unsigned char *fetchPayload(
 ** in the common case where no overflow pages are used.
 */
 const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
-  const void *p = 0;
-  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
-  assert( cursorHoldsMutex(pCur) );
-  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
-    p = (const void*)fetchPayload(pCur, pAmt, 0);
-  }
-  return p;
+  return fetchPayload(pCur, pAmt);
 }
 const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){
-  const void *p = 0;
-  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
-  assert( cursorHoldsMutex(pCur) );
-  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
-    p = (const void*)fetchPayload(pCur, pAmt, 1);
-  }
-  return p;
+  return fetchPayload(pCur, pAmt);
 }