1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Use memmove() rather than a home-made copy loop in dropCell() of btree.c,

for a size reduction and performance improvement.

FossilOrigin-Name: 78e1706804e88a0dd5dc40bee838a3a504cfa53b
This commit is contained in:
drh
2013-12-09 01:58:11 +00:00
parent 29f2bad6f0
commit 9bb7c4ff4f
3 changed files with 8 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Avoid\sunnecessary\sno-op\scalls\sfrom\sgetAndInitPage()\sto\sbtreeInitPage()\s\nin\sthe\sbtree.c\slogic.
D 2013-12-09T01:04:54.208
C Use\smemmove()\srather\sthan\sa\shome-made\scopy\sloop\sin\sdropCell()\sof\sbtree.c,\nfor\sa\ssize\sreduction\sand\sperformance\simprovement.
D 2013-12-09T01:58:11.109
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 368d2eaeea81254d5c7bf7e3d6c1737e08e1e10e
F src/btree.c ac25a91a1ec94b361b09fdd99253b248ab0bbefc
F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9
F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
F src/build.c 9b40580b62916612678bdb69ce0286e39c29a862
@@ -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 6996fb34445adedf463b66ed1f339ee1f27ce6e5
R a6e3d012f7b111fe3cf762bd37b890b8
P 81f5ae13b2e23daee03151d32515387b7f5ba5e5
R dff255530828faccbaffbe7aa2a8b29a
U drh
Z 69daab0d3610fce7f9ad3f7d6b1dfdc6
Z 8d4fe309cbbd963b83317f42164d5ecb

View File

@@ -1 +1 @@
81f5ae13b2e23daee03151d32515387b7f5ba5e5
78e1706804e88a0dd5dc40bee838a3a504cfa53b

View File

@@ -5671,7 +5671,6 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
u32 pc; /* Offset to cell content of cell being deleted */
u8 *data; /* pPage->aData */
u8 *ptr; /* Used to move bytes around within data[] */
u8 *endPtr; /* End of loop */
int rc; /* The return code */
int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */
@@ -5696,13 +5695,8 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
*pRC = rc;
return;
}
endPtr = &pPage->aCellIdx[2*pPage->nCell - 2];
assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */
while( ptr<endPtr ){
*(u16*)ptr = *(u16*)&ptr[2];
ptr += 2;
}
pPage->nCell--;
memmove(ptr, ptr+2, 2*(pPage->nCell - idx));
put2byte(&data[hdr+3], pPage->nCell);
pPage->nFree += 2;
}