PragmaTwice commented on code in PR #775:
URL: https://github.com/apache/incubator-kvrocks/pull/775#discussion_r943699107
##########
src/redis_cmd.cc:
##########
@@ -1602,17 +1602,22 @@ class CommandBPop : public Commander {
rocksdb::Status TryPopFromList() {
Redis::List list_db(svr_->storage_, conn_->GetNamespace());
- std::string last_key, elem;
+ std::string elem;
+ std::string* last_key_ptr = nullptr;
rocksdb::Status s;
for (const auto &key : keys_) {
- last_key = key;
+ last_key = &key;
s = list_db.Pop(key, left_, &elem);
if (s.ok() || !s.IsNotFound()) {
break;
}
}
if (s.ok()) {
- conn_->Reply(Redis::MultiBulkString({last_key, elem}));
+ if (last_key_ptr == nullptr) {
+ conn_->Reply(Redis::MultiBulkString({"", elem}));
+ } else {
+ conn_->Reply(Redis::MultiBulkString({*last_key_ptr, elem}));
Review Comment:
```suggestion
conn_->Reply(Redis::MultiBulkString({*last_key_ptr,
std::move(elem)}));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]