aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-06-30 16:29:59 +0000
committerdrh <drh@noemail.net>2015-06-30 16:29:59 +0000
commit59b4bd48402d7e3fd43c6421c914f941381ad67f (patch)
tree610aac3f446aa781e946a4f01f91496acae59cb9 /src/util.c
parentbe7d4978365fe110e08ad2ef2f4b09a19f350660 (diff)
parentda6d3e2117fd2ab1cbcc0f21ac5839d08d04344e (diff)
downloadsqlite-59b4bd48402d7e3fd43c6421c914f941381ad67f.tar.gz
sqlite-59b4bd48402d7e3fd43c6421c914f941381ad67f.zip
Merge all the latest enhancements from trunk. This merge include FTS5
and a number of notable performance enhancements. FossilOrigin-Name: 39936b33b0668aad81aa574d4d74c92b0ddd218a
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 0bc1eeacf..4e029b0e0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -105,10 +105,8 @@ int sqlite3IsNaN(double x){
** than 1GiB) the value returned might be less than the true string length.
*/
int sqlite3Strlen30(const char *z){
- const char *z2 = z;
if( z==0 ) return 0;
- while( *z2 ){ z2++; }
- return 0x3fffffff & (int)(z2 - z);
+ return 0x3fffffff & (int)strlen(z);
}
/*
@@ -1080,14 +1078,31 @@ int sqlite3VarintLen(u64 v){
** Read or write a four-byte big-endian integer value.
*/
u32 sqlite3Get4byte(const u8 *p){
+#if SQLITE_BYTEORDER==4321
+ u32 x;
+ memcpy(&x,p,4);
+ return x;
+#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__)
+ u32 x;
+ memcpy(&x,p,4);
+ return __builtin_bswap32(x);
+#else
testcase( p[0]&0x80 );
return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
+#endif
}
void sqlite3Put4byte(unsigned char *p, u32 v){
+#if SQLITE_BYTEORDER==4321
+ memcpy(p,&v,4);
+#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__)
+ u32 x = __builtin_bswap32(v);
+ memcpy(p,&x,4);
+#else
p[0] = (u8)(v>>24);
p[1] = (u8)(v>>16);
p[2] = (u8)(v>>8);
p[3] = (u8)v;
+#endif
}