aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 10:08:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 10:08:32 +0100
commit4042cbffcaf3f9e0d273806b065d18d703d4e78e (patch)
tree18916e86bfe267112a32a082356bc1580d917c2d /src
parentbb517fb0e1a031fbee9e25632ada43e371b4b42a (diff)
downloadrspamd-4042cbffcaf3f9e0d273806b065d18d703d4e78e.tar.gz
rspamd-4042cbffcaf3f9e0d273806b065d18d703d4e78e.zip
[Minor] Slightly simplify swap for optimization
Diffstat (limited to 'src')
-rw-r--r--src/libutil/heap.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libutil/heap.c b/src/libutil/heap.c
index 115b2e6a8..47c996732 100644
--- a/src/libutil/heap.c
+++ b/src/libutil/heap.c
@@ -21,13 +21,15 @@ struct rspamd_min_heap {
GPtrArray *ar;
};
+#define __SWAP(a, b) do { \
+ __typeof__(a) _a = (a); \
+ __typeof__(b) _b = (b); \
+ a = _b; \
+ b = _a; \
+} while (0)
#define heap_swap(h,e1,e2) do { \
- gpointer telt = (h)->ar->pdata[(e1)->idx - 1]; \
- (h)->ar->pdata[(e1)->idx - 1] = (h)->ar->pdata[(e2)->idx - 1]; \
- (h)->ar->pdata[(e2)->idx - 1] = telt; \
- guint tidx = (e1)->idx; \
- (e1)->idx = (e2)->idx; \
- (e2)->idx = tidx; \
+ __SWAP((h)->ar->pdata[(e1)->idx - 1], (h)->ar->pdata[(e2)->idx - 1]); \
+ __SWAP((e1)->idx, (e2)->idx); \
} while (0)
#define min_elt(e1, e2) ((e1)->pri <= (e2)->pri ? (e1) : (e2))