Use emplace_back. NFC.

Found by clang-tidy.
pull/487/head
Ryan Pavlik 2019-08-20 14:44:16 -05:00 committed by whitequark
parent 34dccbf935
commit ae417fc14c
2 changed files with 5 additions and 4 deletions

View File

@ -295,7 +295,7 @@ Path Path::Expand(bool fromCurrentDirectory) const {
if(expanded.IsEmpty()) { if(expanded.IsEmpty()) {
if(expandedComponents.empty()) { if(expandedComponents.empty()) {
expandedComponents.push_back("."); expandedComponents.emplace_back(".");
} }
expanded = From(Concat(expandedComponents, SEPARATOR)); expanded = From(Concat(expandedComponents, SEPARATOR));
} else if(!expandedComponents.empty()) { } else if(!expandedComponents.empty()) {
@ -371,12 +371,12 @@ Path Path::RelativeTo(const Path &base) const {
std::vector<std::string> resultComponents; std::vector<std::string> resultComponents;
for(size_t i = common; i < baseComponents.size(); i++) { for(size_t i = common; i < baseComponents.size(); i++) {
resultComponents.push_back(".."); resultComponents.emplace_back("..");
} }
resultComponents.insert(resultComponents.end(), resultComponents.insert(resultComponents.end(),
components.begin() + common, components.end()); components.begin() + common, components.end());
if(resultComponents.empty()) { if(resultComponents.empty()) {
resultComponents.push_back("."); resultComponents.emplace_back(".");
} }
return From(Concat(resultComponents, SEPARATOR)); return From(Concat(resultComponents, SEPARATOR));
} }

View File

@ -77,8 +77,9 @@ void MemFree(void *p) {
std::vector<std::string> InitPlatform(int argc, char **argv) { std::vector<std::string> InitPlatform(int argc, char **argv) {
std::vector<std::string> args; std::vector<std::string> args;
args.reserve(argc);
for(int i = 0; i < argc; i++) { for(int i = 0; i < argc; i++) {
args.push_back(argv[i]); args.emplace_back(argv[i]);
} }
return args; return args;
} }