union RtreeCoord {
RtreeValue f; /* Floating point value */
int i; /* Integer value */
+ u32 u; /* Unsigned for byte-order conversions */
};
/*
}
/*
-** Convert raw bits from the on-disk RTree record into a coordinate value
-** The on-disk record stores integer coordinates if eInt is true and it
-** stores 32-bit floating point records if eInt is false. a[] is the four
+** Convert raw bits from the on-disk RTree record into a coordinate value.
+** The on-disk format is big-endian and needs to be converted for little-endian
+** platforms. The on-disk record stores integer coordinates if eInt is true
+** and it stores 32-bit floating point records if eInt is false. a[] is the four
** bytes of the on-disk record to be decoded. Store the results in "r".
+**
+** The first version of this macro is fast on x86, x86_64 and ARM, all of which
+** are little-endian. The second version of this macro is cross-platform but
+** takes twice as long, according to valgrind on linux x64.
*/
+#if defined(__x86) || defined(__x86_64) || defined(__arm__) || defined(_MSC_VER)
#define RTREE_DECODE_COORD(eInt, a, r) { \
- u32 x; /* Raw bits of the coordinate value */ \
RtreeCoord c; /* Coordinate decoded */ \
- x = ((u32)a[0]<<24) + ((u32)a[1]<<16) \
+ memcpy(&c.u,a,4); \
+ c.u = ((c.u>>24)&0xff)|((c.u>>8)&0xff00)| \
+ ((c.u&0xff)<<24)|((c.u&0xff00)<<8); \
+ r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \
+}
+#else
+#define RTREE_DECODE_COORD(eInt, a, r) { \
+ RtreeCoord c; /* Coordinate decoded */ \
+ c.u = ((u32)a[0]<<24) + ((u32)a[1]<<16) \
+((u32)a[2]<<8) + a[3]; \
- c.i = *(int*)&x; \
r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \
}
+#endif
/*
-C More\stest\scases\swith\svery\slong\spriority\squeues.
-D 2014-04-17T15:34:58.372
+C Performance\soptimization\son\sbyte-swapping\sin\sR-Tree.
+D 2014-04-17T23:23:29.676
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e4ee6d36cdf6136aee0158675a3b24dd3bf31a5a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
-F ext/rtree/rtree.c 6a47918e44697dd32f5bba8a79d3490e56bd76c9
+F ext/rtree/rtree.c 5cf5ae21ca1742be863f025ce64e4262fc6def4c
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
F ext/rtree/rtree1.test cf679265ecafff494a768ac9c2f43a70915a6290
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 1ccaaed6b516ec2ce953c1b31025a82ba76d00e7
-R 449eb9a5ce303ca34184a4306bd9d328
+P 71692aa97c78676f0ba80eaeec0ad9ac225f4427
+R f1ebd50a7930430ccdb2dd222ebc5021
U drh
-Z 39039e877d4cb95ab625ec95bd5cc650
+Z 8e204d3bb697cd291df3586d6cea66ab