Skip to content

Commit

Permalink
Merge pull request #18579 from GermanAizek/emplace_back
Browse files Browse the repository at this point in the history
Minor replaced insert to emplace C++11
  • Loading branch information
hrydgard committed Dec 19, 2023
2 parents ffa3529 + 4ea842a commit f2ee437
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Common/Data/Format/IniFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool Section::GetKeys(std::vector<std::string> &keys) const {
keys.clear();
for (auto liter = lines_.begin(); liter != lines_.end(); ++liter) {
if (!liter->Key().empty())
keys.push_back(std::string(liter->Key()));
keys.emplace_back(liter->Key());
}
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions Common/File/VFS/ZipFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vector<File::File
if (filter) {
while (*filter) {
if (*filter == ':') {
filters.insert("." + tmp);
filters.emplace("." + tmp);
tmp.clear();
} else {
tmp.push_back(*filter);
Expand All @@ -94,7 +94,7 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vector<File::File
}

if (tmp.size())
filters.insert("." + tmp);
filters.emplace("." + tmp);

// We just loop through the whole ZIP file and deduce what files are in this directory, and what subdirectories there are.
std::set<std::string> files;
Expand Down Expand Up @@ -175,7 +175,7 @@ bool ZipFileReader::GetZipListings(const std::string &path, std::set<std::string
anyPrefixMatched = true;
// It's a file.
const char *fn = name + path.size();
files.insert(std::string(fn));
files.emplace(fn);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Common/Math/expression_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf
return false;
}

dest.push_back(ExpressionPair(isFloat?EXCOMM_CONST_FLOAT:EXCOMM_CONST,value));
dest.emplace_back(isFloat?EXCOMM_CONST_FLOAT:EXCOMM_CONST,value);
lastOpcode = EXOP_NUMBER;
} else if ((first >= 'a' && first <= 'z') || first == '@')
{
Expand All @@ -271,14 +271,14 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf
uint32_t value;
if (funcs->parseReference(subStr,value) == true)
{
dest.push_back(ExpressionPair(EXCOMM_REF,value));
dest.emplace_back(EXCOMM_REF,value);
lastOpcode = EXOP_NUMBER;
continue;
}

if (funcs->parseSymbol(subStr,value) == true)
{
dest.push_back(ExpressionPair(EXCOMM_CONST,value));
dest.emplace_back(EXCOMM_CONST,value);
lastOpcode = EXOP_NUMBER;
continue;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf
ExpressionOpcodeType t = opcodeStack[opcodeStack.size()-1];
opcodeStack.pop_back();
if (t == EXOP_BRACKETL) break;
dest.push_back(ExpressionPair(EXCOMM_OP,t));
dest.emplace_back(EXCOMM_OP,t);
}
break;
case EXOP_MEMR:
Expand All @@ -326,10 +326,10 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf
opcodeStack.pop_back();
if (t == EXOP_MEML)
{
dest.push_back(ExpressionPair(EXCOMM_OP,EXOP_MEM));
dest.emplace_back(EXCOMM_OP,EXOP_MEM);
break;
}
dest.push_back(ExpressionPair(EXCOMM_OP,t));
dest.emplace_back(EXCOMM_OP,t);
}
type = EXOP_NUMBER;
break;
Expand All @@ -350,7 +350,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf

if (ExpressionOpcodes[t].Priority >= CurrentPriority)
{
dest.push_back(ExpressionPair(EXCOMM_OP,t));
dest.emplace_back(EXCOMM_OP,t);
} else {
opcodeStack.push_back(t);
break;
Expand All @@ -375,7 +375,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf
expressionError = "Parenthesis not closed";
return false;
}
dest.push_back(ExpressionPair(EXCOMM_OP,t));
dest.emplace_back(EXCOMM_OP,t);
}

#if 0 // only for testing
Expand Down
2 changes: 1 addition & 1 deletion Common/UI/IconCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool IconCache::LoadFromFile(FILE *file) {
entry.format = entryHeader.format;
entry.insertedTimeStamp = entryHeader.insertedTimestamp;
entry.usedTimeStamp = now;
cache_.insert(std::pair<std::string, Entry>(key, entry));
cache_.emplace(key, entry);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/IR/IRNativeCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ void IRNativeBackend::SetBlockCheckedOffset(int block_num, int offset) {
}

void IRNativeBackend::AddLinkableExit(int block_num, uint32_t pc, int exitStartOffset, int exitLen) {
linksTo_.insert(std::make_pair(pc, block_num));
linksTo_.emplace(pc, block_num);

if (block_num >= (int)nativeBlocks_.size())
nativeBlocks_.resize(block_num + 1);
Expand Down
4 changes: 2 additions & 2 deletions Windows/Debugger/CtrlDisAsmView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ std::set<std::string> CtrlDisAsmView::getSelectedLineArguments() {
manager.getLine(addr, displaySymbols, line);
size_t p = 0, nextp = line.params.find(',');
while (nextp != line.params.npos) {
args.insert(line.params.substr(p, nextp - p));
args.emplace(line.params.substr(p, nextp - p));
p = nextp + 1;
nextp = line.params.find(',', p);
}
if (p < line.params.size()) {
args.insert(line.params.substr(p));
args.emplace(line.params.substr(p));
}
}

Expand Down

0 comments on commit f2ee437

Please sign in to comment.