Skip to content

Commit

Permalink
help the compiler find the clone is unnecessary and make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Apr 19, 2024
1 parent b7a57b3 commit 9a8bcac
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/common/meta/src/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,15 @@ impl Inner {

let req = CompareAndPutRequest {
key: key.to_vec(),
expect: expect.clone(),
expect,
value: value.to_vec(),
};

let res = self.generator.compare_and_put(req).await?;

if !res.success {
if let Some(kv) = res.prev_kv {
expect.clone_from(&kv.value);

let v: [u8; 8] = match kv.value.try_into() {
let v: [u8; 8] = match kv.value.clone().try_into() {
Ok(a) => a,
Err(v) => {
return error::UnexpectedSequenceValueSnafu {
Expand All @@ -184,13 +182,12 @@ impl Inner {
}
};
let v = u64::from_le_bytes(v);

// If the existed value is smaller than the initial, we should start from the initial.
start = v.max(self.initial);
expect = kv.value;
} else {
expect = vec![];

start = self.initial;
expect = vec![];
}
continue;
}
Expand Down

0 comments on commit 9a8bcac

Please sign in to comment.