Skip to content

Commit

Permalink
fix lpop/rpop response (OpenAtomFoundation#1893)
Browse files Browse the repository at this point in the history
* fix lpop/rpop response

* formatting: added space for "if"

* formatting code

---------

Co-authored-by: cjh <[email protected]>
  • Loading branch information
cheniujh and cheniujh authored Aug 10, 2023
1 parent f25159c commit 5fd92fd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pika_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ void LPopCmd::Do(std::shared_ptr<Slot> slot) {
rocksdb::Status s = slot->db()->LPop(key_, count_, &elements);

if (s.ok()) {
res_.AppendArrayLenUint64(elements.size());
if (elements.size() > 1) {
res_.AppendArrayLenUint64(elements.size());
}
for (const auto& element : elements) {
res_.AppendString(element);
}
Expand Down Expand Up @@ -558,11 +560,13 @@ void RPopCmd::DoInitial() {
}
}
void RPopCmd::Do(std::shared_ptr<Slot> slot) {
std::vector<std::string> elements;
std::vector <std::string> elements;
rocksdb::Status s = slot->db()->RPop(key_, count_, &elements);
if (s.ok()) {
res_.AppendArrayLenUint64(elements.size());
for (const auto& element : elements) {
if (elements.size() > 1) {
res_.AppendArrayLenUint64(elements.size());
}
for (const auto &element: elements) {
res_.AppendString(element);
}
} else if (s.IsNotFound()) {
Expand Down

0 comments on commit 5fd92fd

Please sign in to comment.