mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-10 01:56:56 +00:00
refactor(gossipsub): use pop
instead of remove
Doesn't change any functionality but `pop` returns an `Option` whereas `remove` will panic on out-of-bounds. I am more comfortable with `pop` and a pattern match. Also, usage of `continue` allows us to not use an `else`. Pull-Request: #3734.
This commit is contained in:
parent
95fa913923
commit
7c85f92e31
@ -450,16 +450,16 @@ impl ConnectionHandler for Handler {
|
||||
) {
|
||||
// outbound idle state
|
||||
Some(OutboundSubstreamState::WaitingOutput(substream)) => {
|
||||
if !self.send_queue.is_empty() {
|
||||
let message = self.send_queue.remove(0);
|
||||
if let Some(message) = self.send_queue.pop() {
|
||||
self.send_queue.shrink_to_fit();
|
||||
self.outbound_substream =
|
||||
Some(OutboundSubstreamState::PendingSend(substream, message));
|
||||
} else {
|
||||
self.outbound_substream =
|
||||
Some(OutboundSubstreamState::WaitingOutput(substream));
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
self.outbound_substream =
|
||||
Some(OutboundSubstreamState::WaitingOutput(substream));
|
||||
break;
|
||||
}
|
||||
Some(OutboundSubstreamState::PendingSend(mut substream, message)) => {
|
||||
match Sink::poll_ready(Pin::new(&mut substream), cx) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user