Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Replace replace(..., None) with take() #1227

Merged
merged 1 commit into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/broadcast_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use log::Level;
use packet::BlobRecycler;
use result::{Error, Result};
use service::Service;
use std::mem;
use std::net::UdpSocket;
use std::sync::atomic::AtomicUsize;
use std::sync::mpsc::RecvTimeoutError;
Expand Down Expand Up @@ -60,7 +59,7 @@ fn broadcast(
for b in &blobs {
let ix = b.read().unwrap().get_index().expect("blob index");
let pos = (ix % WINDOW_SIZE) as usize;
if let Some(x) = mem::replace(&mut win[pos].data, None) {
if let Some(x) = win[pos].data.take() {
trace!(
"{} popped {} at {}",
id,
Expand All @@ -69,7 +68,7 @@ fn broadcast(
);
recycler.recycle(x, "broadcast-data");
}
if let Some(x) = mem::replace(&mut win[pos].coding, None) {
if let Some(x) = win[pos].coding.take() {
trace!(
"{} popped {} at {}",
id,
Expand Down
2 changes: 1 addition & 1 deletion src/erasure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn is_missing(
recycler: &BlobRecycler,
c_or_d: &str,
) -> bool {
if let Some(blob) = mem::replace(window_slot, None) {
if let Some(blob) = window_slot.take() {
let blob_idx = blob.read().unwrap().get_index().unwrap();
if blob_idx == idx {
trace!("recover {}: idx: {} good {}", id, idx, c_or_d);
Expand Down
2 changes: 1 addition & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WindowSlot {
}

fn clear_data(&mut self, recycler: &BlobRecycler) {
if let Some(blob) = mem::replace(&mut self.data, None) {
if let Some(blob) = self.data.take() {
recycler.recycle(blob, "WindowSlot::clear_data");
}
}
Expand Down