Ref: http://en.wikipedia.org/wiki/XOR_swap_algorithm, modern compilers/CPUs are much more efficient with "naive" algo than XOR one.
Doubled check, for me in an optimized build, XOR is several times slower than naive algo.
#endif
/* ensure v0 is smaller */
-#define EDGE_ORD(v0, v1) \
- if (v0 > v1) { \
- v0 ^= v1; \
- v1 ^= v0; \
- v0 ^= v1; \
+#define EDGE_ORD(v0, v1) \
+ if (v0 > v1) { \
+ SWAP(unsigned int, v0, v1); \
} (void)0
/***/
}
/* ensure v0 is smaller */
-#define EDGE_ORD(v0, v1) \
- if (v0 > v1) { \
- v0 ^= v1; \
- v1 ^= v0; \
- v0 ^= v1; \
+#define EDGE_ORD(v0, v1) \
+ if (v0 > v1) { \
+ SWAP(int, v0, v1); \
} (void)0
static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2])