crypto: Remove some unnecessary mem::replace calls.

master
Damir Jelić 2020-06-02 10:36:51 +02:00
parent 21b33f4e61
commit 5175cd8ddb
2 changed files with 5 additions and 7 deletions

View File

@ -14,7 +14,6 @@
use matrix_sdk_common::instant::Instant;
use std::fmt;
use std::mem;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
@ -275,7 +274,7 @@ impl Session {
/// * `message` - The Olm message that should be decrypted.
pub async fn decrypt(&mut self, message: OlmMessage) -> Result<String, OlmSessionError> {
let plaintext = self.inner.lock().await.decrypt(message)?;
mem::replace(&mut self.last_use_time, Arc::new(Instant::now()));
self.last_use_time = Arc::new(Instant::now());
Ok(plaintext)
}
@ -288,7 +287,7 @@ impl Session {
/// * `plaintext` - The plaintext that should be encrypted.
pub async fn encrypt(&mut self, plaintext: &str) -> OlmMessage {
let message = self.inner.lock().await.encrypt(plaintext);
mem::replace(&mut self.last_use_time, Arc::new(Instant::now()));
self.last_use_time = Arc::new(Instant::now());
message
}

View File

@ -15,7 +15,6 @@
use matrix_sdk_common::instant::{Duration, Instant};
use std::collections::{BTreeMap, HashSet};
use std::convert::TryFrom;
use std::mem;
use std::path::{Path, PathBuf};
use std::result::Result as StdResult;
use std::sync::Arc;
@ -597,11 +596,11 @@ impl CryptoStore for SqliteStore {
.for_each(drop);
let devices = self.load_devices().await?;
mem::replace(&mut self.devices, devices);
self.devices = devices;
let (tracked_users, users_for_query) = self.load_tracked_users().await?;
mem::replace(&mut self.tracked_users, tracked_users);
mem::replace(&mut self.users_for_key_query, users_for_query);
self.tracked_users = tracked_users;
self.users_for_key_query = users_for_query;
Ok(result)
}