Replace XOR swapping by default ("naive", with extra var) one.

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.
This commit is contained in:
Bastien Montagne
2014-01-21 15:19:27 +01:00
parent 7198eee880
commit 7acb7cb897
2 changed files with 6 additions and 10 deletions

View File

@@ -59,11 +59,9 @@ static const unsigned int _ehash_hashsizes[] = {
#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
/***/

View File

@@ -90,11 +90,9 @@ static GSet *erot_gset_new(void)
}
/* 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])