Skip to content

Commit

Permalink
style: format new codes
Browse files Browse the repository at this point in the history
  • Loading branch information
longfar-ncy committed Nov 27, 2023
1 parent 7ac0a16 commit 8a6e674
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/base_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const std::string kCmdNameBitCount = "bitcount";

const std::string kCmdNameAuth = "auth";


enum CmdFlags {
CmdFlagsWrite = (1 << 0), // May modify the dataset
CmdFlagsReadonly = (1 << 1), // Doesn't modify the dataset
Expand Down
2 changes: 1 addition & 1 deletion src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ void PClient::FeedMonitors(const std::vector<std::string>& params) {
}
}
void PClient::SetKey(std::vector<std::string>& names) {
keys_ = std::move(names); // use std::move clear copy expense
keys_ = std::move(names); // use std::move clear copy expense
}

} // namespace pikiwidb
6 changes: 4 additions & 2 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class PClient : public std::enable_shared_from_this<PClient>, public CmdRes {
void SetSubCmdName(const std::string& name);
const std::string& SubCmdName() const { return subCmdName_; }
std::string FullCmdName() const; // the full name of the command, such as config set|get|rewrite
void SetKey(const std::string& name) { keys_.clear(); keys_.emplace_back(name); }
void SetKey(const std::string& name) {
keys_.clear();
keys_.emplace_back(name);
}
void SetKey(std::vector<std::string>& names);
const std::string& Key() const { return keys_.at(0); }
const std::vector<std::string>& Keys() const { return keys_; }
Expand Down Expand Up @@ -219,7 +222,6 @@ class PClient : public std::enable_shared_from_this<PClient>, public CmdRes {
std::string cmdName_; // suchAs config
std::vector<std::string> keys_;


// All parameters of this command (including the command itself)
// e.g:["set","key","value"]
std::vector<std::string> params_;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ BitCountCmd::BitCountCmd(const std::string& name, int16_t arity)

bool BitCountCmd::DoInitial(PClient* client) {
size_t paramSize = client->argv_.size();
if(paramSize != 2 && paramSize != 4) {
if (paramSize != 2 && paramSize != 4) {
client->SetRes(CmdRes::kSyntaxErr, kCmdNameBitCount);
return false;
}
Expand All @@ -188,7 +188,7 @@ void BitCountCmd::DoCmd(PClient* client) {
if (pstd::String2int(client->argv_[2], &start_offset_) == 0 ||
pstd::String2int(client->argv_[3], &end_offset_) == 0) {
client->SetRes(CmdRes::kInvalidInt);
return ;
return;
}

auto str = GetDecodedString(value);
Expand Down

0 comments on commit 8a6e674

Please sign in to comment.