mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Performance improvement by avoiding unnecessary calls to memset().
FossilOrigin-Name: 85940468e6f93f7c493fbc129f13cf6233c5d0c0
This commit is contained in:
16
src/btree.c
16
src/btree.c
@@ -3278,8 +3278,8 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
|
||||
** root page of a b-tree. If it is not, then the cursor acquired
|
||||
** will not work correctly.
|
||||
**
|
||||
** It is assumed that the sqlite3BtreeCursorSize() bytes of memory
|
||||
** pointed to by pCur have been zeroed by the caller.
|
||||
** It is assumed that the sqlite3BtreeCursorZero() has been called
|
||||
** on pCur to initialize the memory space prior to invoking this routine.
|
||||
*/
|
||||
static int btreeCursor(
|
||||
Btree *p, /* The btree */
|
||||
@@ -3355,6 +3355,18 @@ int sqlite3BtreeCursorSize(void){
|
||||
return ROUND8(sizeof(BtCursor));
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize memory that will be converted into a BtCursor object.
|
||||
**
|
||||
** The simple approach here would be to memset() the entire object
|
||||
** to zero. But it turns out that the apPage[] and aiIdx[] arrays
|
||||
** do not need to be zeroed and they are large, so we can save a lot
|
||||
** of run-time by skipping the initialization of those elements.
|
||||
*/
|
||||
void sqlite3BtreeCursorZero(BtCursor *p){
|
||||
memset(p, 0, offsetof(BtCursor, iPage));
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the cached rowid value of every cursor in the same database file
|
||||
** as pCur and having the same root page number as pCur. The value is
|
||||
|
Reference in New Issue
Block a user