mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-12 09:59:59 +01:00
string_util: Use emplace_back() in SplitString() instead of push_back()
This is equivalent to doing:
push_back(std::string(""));
which is likely not to cause issues, assuming a decent std::string
implementation with small-string optimizations implemented in its
design, however it's still a little unnecessary to copy that buffer
regardless. Instead, we can use emplace_back() to directly construct the
empty string within the std::vector instance, eliminating any possible
overhead from the copy.
This commit is contained in:
parent
841bb4e5bd
commit
f34dde32d1
@ -230,8 +230,9 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
|
||||
std::istringstream iss(str);
|
||||
output.resize(1);
|
||||
|
||||
while (std::getline(iss, *output.rbegin(), delim))
|
||||
output.push_back("");
|
||||
while (std::getline(iss, *output.rbegin(), delim)) {
|
||||
output.emplace_back();
|
||||
}
|
||||
|
||||
output.pop_back();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user