Skip to content

Commit

Permalink
Use Vec instead of SmallVec
Browse files Browse the repository at this point in the history
In order to not expose a third party dependency in our API use a `Vec`
type for the addresses list instead of a `SmallVec`.
  • Loading branch information
tcharding committed Mar 10, 2020
1 parent f154c81 commit 7e347a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/src/connection/listeners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ where
/// The ID of the listener that closed.
listener_id: ListenerId,
/// The addresses that the listener was listening on.
addresses: SmallVec<[Multiaddr; 4]>,
addresses: Vec<Multiaddr>,
/// Reason for the closure. Contains `Ok(())` if the stream produced `None`, or `Err`
/// if the stream produced an error.
reason: Result<(), TTrans::Error>,
Expand Down Expand Up @@ -285,14 +285,14 @@ where
Poll::Ready(None) => {
return Poll::Ready(ListenersEvent::Closed {
listener_id: *listener_project.id,
addresses: listener.addresses.clone(),
addresses: listener.addresses.to_vec(),
reason: Ok(()),
})
}
Poll::Ready(Some(Err(err))) => {
return Poll::Ready(ListenersEvent::Closed {
listener_id: *listener_project.id,
addresses: listener.addresses.clone(),
addresses: listener.addresses.to_vec(),
reason: Err(err),
})
}
Expand Down
4 changes: 1 addition & 3 deletions core/src/network/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use crate::{
};
use futures::prelude::*;
use std::{error, fmt, hash::Hash};
use smallvec::SmallVec;

/// Event that can happen on the `Network`.
pub enum NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>
Expand All @@ -57,7 +56,7 @@ where
/// The listener ID that closed.
listener_id: ListenerId,
/// The addresses that the listener was listening on.
addresses: SmallVec<[Multiaddr; 4]>,
addresses: Vec<Multiaddr>,
/// Reason for the closure. Contains `Ok(())` if the stream produced `None`, or `Err`
/// if the stream produced an error.
reason: Result<(), TTrans::Error>,
Expand Down Expand Up @@ -347,4 +346,3 @@ where
self.info().to_connected_point()
}
}

0 comments on commit 7e347a0

Please sign in to comment.