Skip to content

Commit

Permalink
fixup! gossipd: use simple inline array for nodes with few channels.
Browse files Browse the repository at this point in the history
Suggested-by: @cdecker
Suggested-by: @niftynei
  • Loading branch information
rustyrussell authored and niftynei committed Apr 9, 2019
1 parent b6494c1 commit d4ab059
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gossipd/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions gossipd/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d4ab059

Please sign in to comment.