diff --git a/src/common/meta/src/kv_backend/memory.rs b/src/common/meta/src/kv_backend/memory.rs index b9c1dd00bbdb..256e31f93ed3 100644 --- a/src/common/meta/src/kv_backend/memory.rs +++ b/src/common/meta/src/kv_backend/memory.rs @@ -268,18 +268,15 @@ impl TxnService for MemoryKvBackend { let do_txn = |txn_op| match txn_op { TxnOp::Put(key, value) => { - kvs.insert(key.clone(), value); + kvs.insert(key, value); TxnOpResponse::ResponsePut(PutResponse { prev_kv: None }) } TxnOp::Get(key) => { - let value = kvs.get(&key); + let value = kvs.get(&key).cloned(); let kvs = value + .map(|value| KeyValue { key, value }) .into_iter() - .map(|value| KeyValue { - key: key.clone(), - value: value.clone(), - }) .collect(); TxnOpResponse::ResponseGet(RangeResponse { kvs, more: false }) } diff --git a/src/log-store/src/raft_engine/backend.rs b/src/log-store/src/raft_engine/backend.rs index fdc92cd49f19..e2cd65c8fa74 100644 --- a/src/log-store/src/raft_engine/backend.rs +++ b/src/log-store/src/raft_engine/backend.rs @@ -103,7 +103,7 @@ impl TxnService for RaftEngineBackend { let do_txn = |txn_op| match txn_op { TxnOp::Put(key, value) => { batch - .put(SYSTEM_NAMESPACE, key.clone(), value) + .put(SYSTEM_NAMESPACE, key, value) .context(RaftEngineSnafu) .map_err(BoxedError::new) .context(meta_error::ExternalSnafu)?; @@ -113,11 +113,8 @@ impl TxnService for RaftEngineBackend { TxnOp::Get(key) => { let value = engine_get(&engine, &key)?.map(|kv| kv.value); let kvs = value + .map(|value| KeyValue { key, value }) .into_iter() - .map(|value| KeyValue { - key: key.clone(), - value, - }) .collect(); Ok(TxnOpResponse::ResponseGet(RangeResponse { kvs,