From fe66c1dcff5d37fa030729cbf9eb82636d670db4 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 9 Dec 2023 21:12:30 +0000 Subject: [PATCH] Force inlining source and target node id lookup in candidate hops 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. --- lightning/src/routing/router.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index c03fbfaf6..590a99daa 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1532,7 +1532,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(hop) => *hop.payer_node_id, @@ -1551,7 +1551,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 { match self { CandidateRouteHop::FirstHop(hop) => Some(hop.details.counterparty.node_id.into()), -- 2.39.5