This is an automated email from the ASF dual-hosted git repository.

git-hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new abbc768bf chore: remove redundant logic in ZSet and JSON command 
implementations (#3726)
abbc768bf is described below

commit abbc768bff33df6ba8d20db8af99d475664235c8
Author: weimeng <[email protected]>
AuthorDate: Wed Oct 28 20:53:19 2026 +0800

    chore: remove redundant logic in ZSet and JSON command implementations 
(#3726)
    
    # Description
    This PR cleans up redundant code in two places
    
    ## Changes
    ### 1. Remove redundant IsNotFound() check in ZSet Add
    (src/types/redis_zset.cc)
    In the ZSet::Add() method, there was a redundant check !s.IsNotFound()
    inside an if (s.ok()) block. Since s.ok() being true already implies the
    status is not NotFound, the additional check is unnecessary.
    ### 2. Remove duplicate ParseInt() call in JSON ArrInsert
    (src/commands/cmd_json.cc)
    The CommandJsonArrInsert::Execute() method was re-parsing args_[3] even
    though it was already parsed in Parse() and stored in the index_ member
    variable. The result of the second parse was assigned to an unused
    variable.
    
    Co-authored-by: weimeng <[email protected]>
---
 src/commands/cmd_json.cc | 2 --
 src/types/redis_zset.cc  | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/commands/cmd_json.cc b/src/commands/cmd_json.cc
index be9ebff08..2a06da508 100644
--- a/src/commands/cmd_json.cc
+++ b/src/commands/cmd_json.cc
@@ -175,8 +175,6 @@ class CommandJsonArrInsert : public Commander {
     redis::Json json(srv->storage, conn->GetNamespace());
 
     Optionals<uint64_t> results;
-    auto parse_result = ParseInt<int>(args_[3], 10);
-
     auto s = json.ArrInsert(ctx, args_[1], args_[2], index_, {args_.begin() + 
4, args_.end()}, &results);
     if (s.IsNotFound()) {
       *output = conn->NilString();
diff --git a/src/types/redis_zset.cc b/src/types/redis_zset.cc
index 1ea50ae91..33e9e3179 100644
--- a/src/types/redis_zset.cc
+++ b/src/types/redis_zset.cc
@@ -63,7 +63,7 @@ rocksdb::Status ZSet::Add(engine::Context &ctx, const Slice 
&user_key, ZAddFlags
       s = storage_->Get(ctx, ctx.GetReadOptions(), member_key, 
&old_score_bytes);
       if (!s.ok() && !s.IsNotFound()) return s;
       if (s.ok()) {
-        if (!s.IsNotFound() && flags.HasNX()) {
+        if (flags.HasNX()) {
           continue;
         }
         double old_score = DecodeDouble(old_score_bytes.data());

Reply via email to