summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-08 14:32:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-08 14:32:07 +0100
commit190613b7dabb97ffcaea79884a622cca09c4037e (patch)
treeaaeecf045b6d62d6f18b5436f672d29a22f7764a
parent0bab2739e1f9923bd704d3a70e99c2bda496f87d (diff)
downloadrspamd-190613b7dabb97ffcaea79884a622cca09c4037e.tar.gz
rspamd-190613b7dabb97ffcaea79884a622cca09c4037e.zip
[Minor] Use more simple swap algorithm
-rw-r--r--src/libutil/heap.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libutil/heap.c b/src/libutil/heap.c
index 354dfedc5..fe88cca88 100644
--- a/src/libutil/heap.c
+++ b/src/libutil/heap.c
@@ -21,14 +21,13 @@ struct rspamd_min_heap {
GPtrArray *ar;
};
-#define XORSWAP_DISTINCT(a, b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define heap_swap(h,e1,e2) do { \
- guintptr a1 = (guintptr)(h)->ar->pdata[(e2)->idx]; \
- guintptr a2 = (guintptr)(h)->ar->pdata[(e1)->idx]; \
- XORSWAP_DISTINCT((e1)->idx, (e2)->idx); \
- XORSWAP_DISTINCT (a1, a2); \
- (h)->ar->pdata[(e2)->idx] = (gpointer)a1; \
- (h)->ar->pdata[(e1)->idx] = (gpointer)a2; \
+ gpointer telt = (h)->ar->pdata[(e1)->idx]; \
+ (h)->ar->pdata[(e1)->idx] = (h)->ar->pdata[(e2)->idx]; \
+ (h)->ar->pdata[(e2)->idx] = telt; \
+ guint tidx = (e1)->idx; \
+ (e1)->idx = (e2)->idx; \
+ (e2)->idx = tidx; \
} while (0)
#define min_elt(e1, e2) ((e1)->pri <= (e2)->pri ? (e1) : (e2))