From d4ab0592c5d966974f45f7942e986b380606bbe3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Apr 2019 14:14:43 +0930 Subject: [PATCH] fixup! gossipd: use simple inline array for nodes with few channels. Suggested-by: @cdecker Suggested-by: @niftynei --- gossipd/routing.c | 2 +- gossipd/routing.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 03c66eb8b..b4e24b75d 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -79,7 +79,7 @@ static struct node_map *empty_node_map(const tal_t *ctx) return map; } -/* We use a simple array until we have too many. */ +/* We use a simple array (with NULL entries) until we have too many. */ static bool node_uses_chan_map(const struct node *node) { /* This is a layering violation: last entry in htable is the table ptr, diff --git a/gossipd/routing.h b/gossipd/routing.h index 3559f9465..0a5027ca8 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -105,6 +105,9 @@ static inline bool chan_eq_scid(const struct chan *c, } HTABLE_DEFINE_TYPE(struct chan, chan_map_scid, hash_scid, chan_eq_scid, chan_map); +/* For a small number of channels (by far the most common) we use a simple + * array, with empty buckets NULL. For larger, we use a proper hash table, + * with the extra allocation that implies. */ #define NUM_IMMEDIATE_CHANS (sizeof(struct chan_map) / sizeof(struct chan *) - 1) struct node {