Skip to content

Commit

Permalink
Don't collect a Vec.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed May 20, 2022
1 parent dc17953 commit 1842b5a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,13 +1772,11 @@ fn build_route_from_hops_internal<L: Deref>(
network_graph: &ReadOnlyNetworkGraph, final_value_msat: u64, final_cltv_expiry_delta: u32,
logger: L, random_seed_bytes: &[u8; 32]) -> Result<Route, LightningError> where L::Target: Logger {

let hop_ids: Vec<NodeId> = core::iter::once(NodeId::from_pubkey(&our_node_pubkey))
.chain(hops.iter().map(|hop_pubkey| NodeId::from_pubkey(&hop_pubkey))).collect();

let filter_by_nodeids = |_short_channel_id: u64, _send_amt_msat: u64, _capacity_msat: u64,
source: &NodeId, target: &NodeId| {
if hop_ids.iter().find(|x| **x == *source).is_some()
&& hop_ids.iter().find(|x| **x == *target).is_some() {
let mut hop_iter = core::iter::once(NodeId::from_pubkey(&our_node_pubkey)).chain(hops.iter().map(|hop_pubkey| NodeId::from_pubkey(&hop_pubkey)));
if hop_iter.clone().find(|x| *x == *source).is_some()
&& hop_iter.find(|x| *x == *target).is_some() {
0
} else {
u64::max_value()
Expand Down

0 comments on commit 1842b5a

Please sign in to comment.