From 9c01bc2ea2602d8d4b40768f47812e4a2a5eb2cc Mon Sep 17 00:00:00 2001 From: WenyXu Date: Wed, 18 Oct 2023 10:08:05 +0000 Subject: [PATCH] chore: apply suggestions from CR --- src/common/meta/src/rpc/store.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/common/meta/src/rpc/store.rs b/src/common/meta/src/rpc/store.rs index 2ff076b87089..b307894337f2 100644 --- a/src/common/meta/src/rpc/store.rs +++ b/src/common/meta/src/rpc/store.rs @@ -32,18 +32,13 @@ use crate::error::Result; use crate::rpc::{util, KeyValue}; pub fn to_range(key: Vec, range_end: Vec) -> (Bound>, Bound>) { - if range_end.is_empty() { - (Bound::Included(key.clone()), Bound::Included(key.clone())) - } else if range_end.len() == 1 && range_end[0] == 0 { + match (&key[..], &range_end[..]) { + (_, []) => (Bound::Included(key.clone()), Bound::Included(key)), // If both key and range_end are ‘\0’, then range represents all keys. - if key.len() == 1 && key[0] == 0 { - (Bound::Unbounded, Bound::Unbounded) - } else { - // If range_end is ‘\0’, the range is all keys greater than or equal to the key argument. - (Bound::Included(key), Bound::Unbounded) - } - } else { - (Bound::Included(key), Bound::Excluded(range_end)) + ([0], [0]) => (Bound::Unbounded, Bound::Unbounded), + // If range_end is ‘\0’, the range is all keys greater than or equal to the key argument. + (_, [0]) => (Bound::Included(key), Bound::Unbounded), + (_, _) => (Bound::Included(key), Bound::Excluded(range_end)), } }