提交 cd278584 编写于 作者: I Igor Canadi

Clean up StringSplit

Summary: stringSplit is not how we name our functions. Also, we had two StringSplit's in the codebase

Test Plan: make check

Reviewers: yhchiang, dhruba

Reviewed By: dhruba

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D29361
上级 d8406999
......@@ -3058,8 +3058,8 @@ int main(int argc, char** argv) {
dbstats = rocksdb::CreateDBStatistics();
}
std::vector<std::string> fanout =
rocksdb::stringSplit(FLAGS_max_bytes_for_level_multiplier_additional, ',');
std::vector<std::string> fanout = rocksdb::StringSplit(
FLAGS_max_bytes_for_level_multiplier_additional, ',');
for (unsigned int j= 0; j < fanout.size(); j++) {
FLAGS_max_bytes_for_level_multiplier_additional_v.push_back(
std::stoi(fanout[j]));
......
......@@ -92,7 +92,7 @@ LDBCommand* LDBCommand::InitFromCmdLineArgs(
for (const auto& arg : args) {
if (arg[0] == '-' && arg[1] == '-'){
vector<string> splits = stringSplit(arg, '=');
vector<string> splits = StringSplit(arg, '=');
if (splits.size() == 2) {
string optionKey = splits[0].substr(OPTION_PREFIX.size());
option_map[optionKey] = splits[1];
......
......@@ -10,7 +10,7 @@
namespace rocksdb {
std::vector<std::string> stringSplit(std::string arg, char delim) {
std::vector<std::string> StringSplit(const std::string& arg, char delim) {
std::vector<std::string> splits;
std::stringstream ss(arg);
std::string item;
......
......@@ -10,6 +10,6 @@
#pragma once
namespace rocksdb {
extern std::vector<std::string> stringSplit(std::string arg, char delim);
extern std::vector<std::string> StringSplit(const std::string& arg, char delim);
} // namespace rocksdb
......@@ -17,6 +17,7 @@
#include <limits>
#include "db/filename.h"
#include "util/coding.h"
#include "util/string_util.h"
//
// There are two types of keys. The first type of key-values
......@@ -116,9 +117,8 @@ Status GeoDBImpl::GetById(const Slice& id, GeoObject* object) {
}
// split the key into p + quadkey + id + lat + lon
std::vector<std::string> parts;
Slice key = iter->key();
StringSplit(&parts, key.ToString(), ':');
std::vector<std::string> parts = StringSplit(key.ToString(), ':');
assert(parts.size() == 5);
assert(parts[0] == "p");
assert(parts[1] == quadkey);
......@@ -180,9 +180,8 @@ Status GeoDBImpl::SearchRadial(const GeoPosition& pos,
number_of_values > 0 && iter->Valid() && iter->status().ok();
iter->Next()) {
// split the key into p + quadkey + id + lat + lon
std::vector<std::string> parts;
Slice key = iter->key();
StringSplit(&parts, key.ToString(), ':');
std::vector<std::string> parts = StringSplit(key.ToString(), ':');
assert(parts.size() == 5);
assert(parts[0] == "p");
std::string* quadkey = &parts[1];
......@@ -243,16 +242,6 @@ std::string GeoDBImpl::MakeQuadKeyPrefix(std::string quadkey) {
return key;
}
void GeoDBImpl::StringSplit(std::vector<std::string>* tokens,
const std::string &text, char sep) {
std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) {
tokens->push_back(text.substr(start, end - start));
start = end + 1;
}
tokens->push_back(text.substr(start));
}
// convert degrees to radians
double GeoDBImpl::radians(double x) {
return (x * PI) / 180;
......
......@@ -169,11 +169,6 @@ class GeoDBImpl : public GeoDB {
double radius,
std::vector<std::string>* quadKeys);
// splits a string into its components
static void StringSplit(std::vector<std::string>* tokens,
const std::string &text,
char sep);
//
// Create keys for accessing rocksdb table(s)
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册