mvcc/txn: use raw_key in Error and reduce copy.
@@ -159,7 +159,7 @@ impl<S: Snapshot> MvccTxn<S> {
start_ts: self.start_ts,
conflict_start_ts: write.start_ts,
conflict_commit_ts: commit,
- key: key.to_raw()?,
+ key: key.into_raw()?,
primary: primary.to_vec(),
});
}
@@ -168,7 +168,9 @@ impl<S: Snapshot> MvccTxn<S> {
|| (write.write_type != WriteType::Delete
&& self.key_exist(&key, write.start_ts - 1)?)
{
- return Err(Error::AlreadyExist { key: key.to_raw()? });
+ return Err(Error::AlreadyExist {
+ key: key.into_raw()?,
+ });
}
}
}
@@ -177,7 +179,7 @@ impl<S: Snapshot> MvccTxn<S> {
if let Some(lock) = self.reader.load_lock(&key)? {
if lock.ts != self.start_ts {
return Err(Error::KeyIsLocked {
- key: key.to_raw()?,
+ key: key.into_raw()?,
primary: lock.primary,
ts: lock.ts,
ttl: lock.ttl,
@@ -223,7 +225,7 @@ impl<S: Snapshot> MvccTxn<S> {
Err(Error::TxnLockNotFound {
start_ts: self.start_ts,
commit_ts,
- key: key.as_encoded().to_owned(),
+ key: key.into_raw()?,
})
}
// Committed by concurrent transaction.
