db/upnp/Util: "emplace" items into the list

Reduce overhead.
This commit is contained in:
Max Kellermann 2014-01-22 09:40:30 +01:00
parent fd754ff8f8
commit 2722b8a3df
1 changed files with 3 additions and 3 deletions

View File

@ -107,15 +107,15 @@ stringToTokens(const std::string &str,
// Add token to the vector and adjust start // Add token to the vector and adjust start
if (pos == std::string::npos) { if (pos == std::string::npos) {
tokens.push_back(str.substr(startPos)); tokens.emplace_back(str, startPos);
break; break;
} else if (pos == startPos) { } else if (pos == startPos) {
// Dont' push empty tokens after first // Dont' push empty tokens after first
if (tokens.empty()) if (tokens.empty())
tokens.push_back(std::string()); tokens.emplace_back();
startPos = ++pos; startPos = ++pos;
} else { } else {
tokens.push_back(str.substr(startPos, pos - startPos)); tokens.emplace_back(str, startPos, pos - startPos);
startPos = ++pos; startPos = ++pos;
} }
} }