diff options
| author | Rafael Zalamena <rzalamena@gmail.com> | 2017-06-16 10:44:31 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@gmail.com> | 2017-06-16 10:44:31 -0300 |
| commit | 45926e58749924a6ff207cf211de3e6457578ecc (patch) | |
| tree | 36fc6b1e0f38826a3cc809e77e39d54c0588832a /ldpd/adjacency.c | |
| parent | f43cd318b26a3dc57a0e6f40bcccdd5ce1886432 (diff) | |
lib: improve the RB implementation
Switch the RB tree implementation completely to the new dlg@'s version
that uses pre-declared functions instead of macros for tree functions.
Original e-mail/diff:
https://marc.info/?l=openbsd-tech&m=147087487111068&w=2
Pros:
* Reduces the amount of code that the usage of those macros generate
* Allows the compiler to do a better compile-time check job
* Might have better i-cache utilization since the tree code is shared
Con:
* dlg@ benchmarks shows it has 'very slightly slower' insertions
* imported RB_* code must adapt the following calls:
RB_INIT(), RB_GENERATE(), RB_ROOT(), RB_EMPTY(), make compare
functions use 'const' (if not already) and maybe others.
Diffstat (limited to 'ldpd/adjacency.c')
| -rw-r--r-- | ldpd/adjacency.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 52e2776654..8a2252e722 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -25,9 +25,9 @@ #include "ldpe.h" #include "log.h" -static __inline int adj_compare(struct adj *, struct adj *); +static __inline int adj_compare(const struct adj *, const struct adj *); static int adj_itimer(struct thread *); -static __inline int tnbr_compare(struct tnbr *, struct tnbr *); +static __inline int tnbr_compare(const struct tnbr *, const struct tnbr *); static void tnbr_del(struct ldpd_conf *, struct tnbr *); static void tnbr_start(struct tnbr *); static void tnbr_stop(struct tnbr *); @@ -41,7 +41,7 @@ RB_GENERATE(ia_adj_head, adj, ia_entry, adj_compare) RB_GENERATE(tnbr_head, tnbr, entry, tnbr_compare) static __inline int -adj_compare(struct adj *a, struct adj *b) +adj_compare(const struct adj *a, const struct adj *b) { if (adj_get_af(a) < adj_get_af(b)) return (-1); @@ -220,7 +220,7 @@ adj_stop_itimer(struct adj *adj) /* targeted neighbors */ static __inline int -tnbr_compare(struct tnbr *a, struct tnbr *b) +tnbr_compare(const struct tnbr *a, const struct tnbr *b) { if (a->af < b->af) return (-1); |
