Changing string splitter function for better efficiency
This commit is contained in:
parent
c64aaab193
commit
1a224e2adc
@ -88,7 +88,7 @@ public:
|
||||
// }
|
||||
std::vector<std::string> textCoord;
|
||||
for(unsigned i = 0; i < routeParameters.viaPoints.size(); ++i) {
|
||||
textCoord = split (routeParameters.viaPoints[i], ',');
|
||||
stringSplit (routeParameters.viaPoints[i], ',', textCoord);
|
||||
if(textCoord.size() != 2) {
|
||||
reply = http::Reply::stockReply(http::Reply::badRequest);
|
||||
return;
|
||||
|
@ -113,19 +113,13 @@ inline std::string & replaceAll(std::string &s, const std::string &sub, const st
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
|
||||
inline void stringSplit(const std::string &s, const char delim, std::vector<std::string>& result) {
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
while(std::getline(ss, item, delim)) {
|
||||
if(item.size() > 0)
|
||||
elems.push_back(item);
|
||||
result.push_back(item);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
inline std::vector<std::string> split(const std::string &s, char delim) {
|
||||
std::vector<std::string> elems;
|
||||
return split(s, delim, elems);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user