mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 13:57:58 +00:00
Use mem::take instead of mem::replace where appropriate (#5846)
* replace replace with take * Update client/api/src/cht.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/api/src/cht.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -109,13 +109,13 @@ impl BatchVerifier {
|
||||
self.sr25519_items.push(Sr25519BatchItem { signature, pub_key, message });
|
||||
|
||||
if self.sr25519_items.len() >= 128 {
|
||||
let items = std::mem::replace(&mut self.sr25519_items, vec![]);
|
||||
let items = std::mem::take(&mut self.sr25519_items);
|
||||
if self.spawn_verification_task(move || Self::verify_sr25519_batch(items)).is_err() {
|
||||
log::debug!(
|
||||
target: "runtime",
|
||||
"Batch-verification returns false because failed to spawn background task.",
|
||||
);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl BatchVerifier {
|
||||
/// aggregated result.
|
||||
#[must_use]
|
||||
pub fn verify_and_clear(&mut self) -> bool {
|
||||
let pending = std::mem::replace(&mut self.pending_tasks, vec![]);
|
||||
let pending = std::mem::take(&mut self.pending_tasks);
|
||||
let started = std::time::Instant::now();
|
||||
|
||||
log::trace!(
|
||||
@@ -145,7 +145,7 @@ impl BatchVerifier {
|
||||
self.sr25519_items.len(),
|
||||
);
|
||||
|
||||
if !Self::verify_sr25519_batch(std::mem::replace(&mut self.sr25519_items, vec![])) {
|
||||
if !Self::verify_sr25519_batch(std::mem::take(&mut self.sr25519_items)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user