diff options
| author | 2018-07-22 15:36:30 -0400 | |
|---|---|---|
| committer | 2018-07-22 15:36:32 -0400 | |
| commit | 26a157cd31676f419420078e7d99df90d9fbc910 (patch) | |
| tree | 50a66cdeb25823c1f4b7bcf496bb8e92f08bd2e2 /src/common/string_util.cpp | |
| parent | string_util: Remove unnecessary std::string instance in TabsToSpaces() (diff) | |
| download | yuzu-26a157cd31676f419420078e7d99df90d9fbc910.tar.gz yuzu-26a157cd31676f419420078e7d99df90d9fbc910.tar.xz yuzu-26a157cd31676f419420078e7d99df90d9fbc910.zip | |
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.
Diffstat (limited to 'src/common/string_util.cpp')
| -rw-r--r-- | src/common/string_util.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 2099eebb8..6737655a5 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -162,8 +162,9 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri | |||
| 162 | std::istringstream iss(str); | 162 | std::istringstream iss(str); |
| 163 | output.resize(1); | 163 | output.resize(1); |
| 164 | 164 | ||
| 165 | while (std::getline(iss, *output.rbegin(), delim)) | 165 | while (std::getline(iss, *output.rbegin(), delim)) { |
| 166 | output.push_back(""); | 166 | output.emplace_back(); |
| 167 | } | ||
| 167 | 168 | ||
| 168 | output.pop_back(); | 169 | output.pop_back(); |
| 169 | } | 170 | } |