Skip to content

Commit

Permalink
Reduce clone
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Nov 15, 2022
1 parent 3bfa4b5 commit 213fb04
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/storage/mvcc/reader/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,15 @@ impl<S: EngineSnapshot> MvccReader<S> {
break;
}
}
let user_key = key.clone().truncate_ts()?;
let commit_ts = key.decode_ts()?;
let user_key = key.truncate_ts()?;
// To make sure we only check each unique user key once and the filter returns
// true.
let should_skip = (cur_key.is_some() && cur_key.clone().unwrap() == user_key)
|| !filter(&user_key, commit_ts);
cur_key = Some(user_key.clone());
if should_skip {
let is_same_user_key = cur_key.as_ref() == Some(&user_key);
if !is_same_user_key {
cur_key = Some(user_key.clone());
}
if is_same_user_key || !filter(&user_key, commit_ts) {
cursor.next(&mut self.statistics.write);
continue;
}
Expand Down

0 comments on commit 213fb04

Please sign in to comment.