1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Remove the use of htonl() in the previous check-in due to linkage issues.

Add the get2byteAligned() macro and use it for access to the cell offsets
on btree pages for about a 1% performance gain.

FossilOrigin-Name: 79ff36b7170c9e7e7a9935c8b9d1665867771087
This commit is contained in:
drh
2015-06-30 13:28:18 +00:00
parent 5372e4d4f9
commit 329428e208
5 changed files with 29 additions and 23 deletions

View File

@@ -691,3 +691,16 @@ struct IntegrityCk {
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
#define get4byte sqlite3Get4byte
#define put4byte sqlite3Put4byte
/*
** get2byteAligned(), unlike get2byte(), requires that its argument point to a
** two-byte aligned address. get2bytea() is only used for accessing the
** cell addresses in a btree header.
*/
#if SQLITE_BYTEORDER==4321
# define get2byteAligned(x) (*(u16*)(x))
#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__)
# define get2byteAligned(x) __builtin_bswap16(*(u16*)(x))
#else
# define get2byteAligned(x) ((x)[0]<<8 | (x)[1])
#endif