Skip to content

Commit

Permalink
fix: use set for virtual link destinations
Browse files Browse the repository at this point in the history
  • Loading branch information
dadada committed Jan 9, 2025
1 parent b0542a0 commit 9e3eb4b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions a653rs-router/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use a653rs::{
prelude::Name,
};
use core::{ops::Deref, str::FromStr, time::Duration};
use heapless::{LinearMap, String, Vec};
use heapless::{FnvIndexSet, LinearMap, String};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -260,7 +260,7 @@ pub struct VirtualLinkConfig<const D: usize> {
pub src: PortName,
/// Destinations
#[cfg_attr(feature = "serde", serde(rename = "destinations"))]
pub dsts: Vec<PortName, D>,
pub dsts: FnvIndexSet<PortName, D>,
/// Minimum transmission interval
pub period: Duration,
}
Expand Down Expand Up @@ -408,8 +408,11 @@ impl<const IN: usize, const OUT: usize, const IFS: usize, const PORTS: usize>
return Err(RouterConfigError::Destination);
};
let vl = self.find_vl(&vl_id)?;
vl.dsts.push(dst).or(Err(RouterConfigError::Storage))?;
Ok(self)
if !vl.dsts.insert(dst).or(Err(RouterConfigError::Storage))? {
Err(RouterConfigError::Destination)
} else {
Ok(self)
}
}

fn contains_resource(&mut self, dst: &PortName) -> bool {
Expand Down

0 comments on commit 9e3eb4b

Please sign in to comment.