From b5ff0c4deeb93804134a4eaac2aaa4b78b86d812 Mon Sep 17 00:00:00 2001 From: zxj Date: Wed, 18 May 2022 16:18:47 +0800 Subject: [PATCH] edit recv_all --- src/fast_log.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/fast_log.rs b/src/fast_log.rs index a8926af..dd919d6 100644 --- a/src/fast_log.rs +++ b/src/fast_log.rs @@ -160,8 +160,9 @@ pub fn init(config: Config) -> Result<&'static Logger, LogError> { if let Ok(mut data) = data { let mut remain; if LOG_SENDER.recv.len() > 0 { - remain = recv_all(&LOG_SENDER.recv); - remain.insert(0, data); + remain = Vec::with_capacity(LOG_SENDER.recv.len()); + remain.push(data); + recv_all(&mut remain,&LOG_SENDER.recv); } else { remain = vec![data]; } @@ -190,8 +191,7 @@ pub fn init(config: Config) -> Result<&'static Logger, LogError> { } } -fn recv_all(recver: &Receiver) -> Vec { - let mut data = Vec::with_capacity(recver.len()); +fn recv_all(data: &mut Vec,recver: &Receiver) { loop { match recver.try_recv() { Ok(v) => { @@ -202,7 +202,6 @@ fn recv_all(recver: &Receiver) -> Vec { } } } - data }