Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supplements of guideline of compilation on macOS with make and clean up some code #334

Merged
merged 6 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ sudo yum install -y epel-release && sudo yum install -y git gcc gcc-c++ make sna
sudo apt-get install gcc g++ make libsnappy-dev autoconf automake libtool which libgtest-dev

# MACOSX
brew install snappy googletest
brew install autoconf automake libtool snappy googletest
ShooterIT marked this conversation as resolved.
Show resolved Hide resolved
```

It is as simple as:
Expand Down
2 changes: 1 addition & 1 deletion src/cron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Status Cron::SetScheduleTime(const std::vector<std::string> &args) {
if (!s.IsOK()) {
return Status(Status::NotOK, "time expression format error : " + s.Msg());
}
new_schedulers.push_back(st);
new_schedulers.emplace_back(std::move(st));
LykxSassinator marked this conversation as resolved.
Show resolved Hide resolved
}
schedulers_ = std::move(new_schedulers);
return Status::OK();
Expand Down
2 changes: 1 addition & 1 deletion src/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ class CommandHMSet : public Commander {
Redis::Hash hash_db(svr->storage_, conn->GetNamespace());
std::vector<FieldValue> field_values;
for (unsigned int i = 2; i < args_.size(); i += 2) {
field_values.push_back(FieldValue{args_[i], args_[i + 1]});
field_values.emplace_back(FieldValue{args_[i], args_[i + 1]});
}
rocksdb::Status s = hash_db.MSet(args_[1], field_values, false, &ret);
if (!s.ok()) {
Expand Down
11 changes: 6 additions & 5 deletions src/redis_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ rocksdb::Status Database::FindKeyRangeWithPrefix(const std::string &prefix,
if (cf_handle == nullptr) {
cf_handle = metadata_cf_handle_;
}
if (prefix.empty()) {
return rocksdb::Status::NotFound();
}
begin->clear();
end->clear();

Expand All @@ -383,10 +386,8 @@ rocksdb::Status Database::FindKeyRangeWithPrefix(const std::string &prefix,
// it's ok to increase the last char in prefix as the boundary of the prefix
// while we limit the namespace last char shouldn't be larger than 128.
std::string next_prefix = prefix;
char last_char = next_prefix.back();
last_char++;
next_prefix.pop_back();
next_prefix.push_back(last_char);
auto prefix_size = prefix.size();
next_prefix[prefix_size - 1] ++;
LykxSassinator marked this conversation as resolved.
Show resolved Hide resolved
iter->SeekForPrev(next_prefix);
int max_prev_limit = 128; // prevent unpredicted long while loop
int i = 0;
Expand Down Expand Up @@ -475,7 +476,7 @@ std::string WriteBatchLogData::Encode() {
}

Status WriteBatchLogData::Decode(const rocksdb::Slice &blob) {
std::string log_data = blob.ToString();
const std::string& log_data = blob.ToString();
std::vector<std::string> args;
Util::Split(log_data, " ", &args);
type_ = static_cast<RedisType >(std::stoi(args[0]));
Expand Down
4 changes: 2 additions & 2 deletions src/redis_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ rocksdb::Status Hash::MGet(const Slice &user_key,
rocksdb::Status Hash::Set(const Slice &user_key, const Slice &field, const Slice &value, int *ret) {
FieldValue fv = {field.ToString(), value.ToString()};
std::vector<FieldValue> fvs;
fvs.push_back(fv);
fvs.emplace_back(std::move(fv));
return MSet(user_key, fvs, false, ret);
}

rocksdb::Status Hash::SetNX(const Slice &user_key, const Slice &field, Slice value, int *ret) {
FieldValue fv = {field.ToString(), value.ToString()};
std::vector<FieldValue> fvs;
fvs.push_back(fv);
fvs.emplace_back(std::move(fv));
return MSet(user_key, fvs, true, ret);
}

Expand Down
1 change: 0 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ Status SockConnect(std::string host, uint32_t port, int *fd, uint64_t conn_timeo
return Status(Status::NotOK, strerror(errno));
}
SockSetTcpNoDelay(*fd, 1);
SockSetTcpNoDelay(*fd, 1);
}
if (timeout > 0) {
struct timeval tv;
Expand Down