Skip to content

Commit

Permalink
Force inlining source and target node id lookup in candidate hops
Browse files Browse the repository at this point in the history
Because our router is rather large, LLVM doesn't always decide to
inline small functions in it, opting instead for a call. This is
somewhat wasteful when we do repeated `match`es on the same data,
so here we force inlining of the `source` and `target` `NodeId`
lookups.
  • Loading branch information
TheBlueMatt committed Dec 10, 2023
1 parent 820afdd commit 97df8ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ impl<'a> CandidateRouteHop<'a> {
/// Source node id refers to the node forwarding the HTLC through this hop.
///
/// For [`Self::FirstHop`] we return payer's node id.
#[inline]
#[inline(always)]
pub fn source(&self) -> NodeId {
match self {
CandidateRouteHop::FirstHop { payer_node_id, .. } => **payer_node_id,
Expand All @@ -1279,7 +1279,7 @@ impl<'a> CandidateRouteHop<'a> {
///
/// For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source,
/// and such a return value would be somewhat nonsensical.
#[inline]
#[inline(always)]
pub fn target(&self) -> Option<NodeId> {
match self {
CandidateRouteHop::FirstHop { details, .. } => Some(details.counterparty.node_id.into()),
Expand Down

0 comments on commit 97df8ee

Please sign in to comment.