diff --git a/db/db_bench.cc b/db/db_bench.cc index 54ede5161..2b5d6c9c3 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -3058,8 +3058,8 @@ int main(int argc, char** argv) { dbstats = rocksdb::CreateDBStatistics(); } - std::vector fanout = - rocksdb::stringSplit(FLAGS_max_bytes_for_level_multiplier_additional, ','); + std::vector 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])); diff --git a/util/ldb_cmd.cc b/util/ldb_cmd.cc index d35b9412c..9a5ec5185 100644 --- a/util/ldb_cmd.cc +++ b/util/ldb_cmd.cc @@ -92,7 +92,7 @@ LDBCommand* LDBCommand::InitFromCmdLineArgs( for (const auto& arg : args) { if (arg[0] == '-' && arg[1] == '-'){ - vector splits = stringSplit(arg, '='); + vector splits = StringSplit(arg, '='); if (splits.size() == 2) { string optionKey = splits[0].substr(OPTION_PREFIX.size()); option_map[optionKey] = splits[1]; diff --git a/util/string_util.cc b/util/string_util.cc index 97b7f9de9..4e0bc4668 100644 --- a/util/string_util.cc +++ b/util/string_util.cc @@ -10,7 +10,7 @@ namespace rocksdb { -std::vector stringSplit(std::string arg, char delim) { +std::vector StringSplit(const std::string& arg, char delim) { std::vector splits; std::stringstream ss(arg); std::string item; diff --git a/util/string_util.h b/util/string_util.h index 676f4aae8..b9f0a1d28 100644 --- a/util/string_util.h +++ b/util/string_util.h @@ -10,6 +10,6 @@ #pragma once namespace rocksdb { -extern std::vector stringSplit(std::string arg, char delim); +extern std::vector StringSplit(const std::string& arg, char delim); } // namespace rocksdb diff --git a/utilities/geodb/geodb_impl.cc b/utilities/geodb/geodb_impl.cc index 56cfa954e..194e51232 100644 --- a/utilities/geodb/geodb_impl.cc +++ b/utilities/geodb/geodb_impl.cc @@ -17,6 +17,7 @@ #include #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 parts; Slice key = iter->key(); - StringSplit(&parts, key.ToString(), ':'); + std::vector 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 parts; Slice key = iter->key(); - StringSplit(&parts, key.ToString(), ':'); + std::vector 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* 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; diff --git a/utilities/geodb/geodb_impl.h b/utilities/geodb/geodb_impl.h index c7e410458..94b2d6ceb 100644 --- a/utilities/geodb/geodb_impl.h +++ b/utilities/geodb/geodb_impl.h @@ -169,11 +169,6 @@ class GeoDBImpl : public GeoDB { double radius, std::vector* quadKeys); - // splits a string into its components - static void StringSplit(std::vector* tokens, - const std::string &text, - char sep); - // // Create keys for accessing rocksdb table(s) //