mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Better readability and optimization insertion into container by replacing 'insert' -> 'emplace', 'push_back' -> 'emplace_back'
This commit is contained in:
parent
c953bf7fc7
commit
3cdf72b68b
@ -206,7 +206,7 @@ void Section::Set(const char* key, const char* newValue)
|
||||
else
|
||||
{
|
||||
// The key did not already exist in this section - let's add it.
|
||||
lines.push_back(std::string(key) + " = " + EscapeComments(newValue));
|
||||
lines.emplace_back(std::string(key) + " = " + EscapeComments(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ void Section::Set(const char* key, const std::vector<std::string>& newValues)
|
||||
}
|
||||
|
||||
void Section::AddComment(const std::string &comment) {
|
||||
lines.push_back("# " + comment);
|
||||
lines.emplace_back("# " + comment);
|
||||
}
|
||||
|
||||
bool Section::Get(const char* key, std::vector<std::string>& values)
|
||||
|
@ -148,7 +148,7 @@ std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const
|
||||
std::string tmp;
|
||||
while (*filter) {
|
||||
if (*filter == ':') {
|
||||
filters.insert("." + tmp);
|
||||
filters.emplace("." + tmp);
|
||||
tmp.clear();
|
||||
} else {
|
||||
tmp.push_back(*filter);
|
||||
@ -156,7 +156,7 @@ std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const
|
||||
filter++;
|
||||
}
|
||||
if (!tmp.empty())
|
||||
filters.insert("." + tmp);
|
||||
filters.emplace("." + tmp);
|
||||
}
|
||||
|
||||
auto pred = [&](const File::FileInfo &info) {
|
||||
|
@ -51,7 +51,7 @@ static void ParseExtensionsString(const std::string& str, std::set<std::string>
|
||||
size_t next = 0;
|
||||
for (size_t pos = 0, len = str.length(); pos < len; ++pos) {
|
||||
if (str[pos] == ' ') {
|
||||
output.insert(str.substr(next, pos - next));
|
||||
output.emplace(str.substr(next, pos - next));
|
||||
// Skip the delimiter itself.
|
||||
next = pos + 1;
|
||||
}
|
||||
@ -60,7 +60,7 @@ static void ParseExtensionsString(const std::string& str, std::set<std::string>
|
||||
if (next == 0 && str.length() != 0) {
|
||||
output.insert(str);
|
||||
} else if (next < str.length()) {
|
||||
output.insert(str.substr(next));
|
||||
output.emplace(str.substr(next));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1432,7 @@ std::vector<std::string> VKContext::GetFeatureList() const {
|
||||
AddFeature(features, "occlusionQueryPrecise", available.occlusionQueryPrecise, enabled.occlusionQueryPrecise);
|
||||
AddFeature(features, "multiDrawIndirect", available.multiDrawIndirect, enabled.multiDrawIndirect);
|
||||
|
||||
features.push_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat));
|
||||
features.emplace_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat));
|
||||
|
||||
return features;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ bool ShouldLogNTimes(const char *identifier, int count) {
|
||||
std::lock_guard<std::mutex> lock(logNTimesLock);
|
||||
auto iter = logNTimes.find(identifier);
|
||||
if (iter == logNTimes.end()) {
|
||||
logNTimes.insert(std::pair<const char*, int>(identifier, 1));
|
||||
logNTimes.emplace(identifier, 1);
|
||||
return true;
|
||||
} else {
|
||||
if (iter->second >= count) {
|
||||
|
@ -273,7 +273,7 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
|
||||
size_t next = 0;
|
||||
for (size_t pos = 0, len = str.length(); pos < len; ++pos) {
|
||||
if (str[pos] == delim) {
|
||||
output.push_back(str.substr(next, pos - next));
|
||||
output.emplace_back(str.substr(next, pos - next));
|
||||
// Skip the delimiter itself.
|
||||
next = pos + 1;
|
||||
}
|
||||
@ -282,7 +282,7 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
|
||||
if (next == 0) {
|
||||
output.push_back(str);
|
||||
} else if (next < str.length()) {
|
||||
output.push_back(str.substr(next));
|
||||
output.emplace_back(str.substr(next));
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ void GetQuotedStrings(const std::string& str, std::vector<std::string>& output)
|
||||
if (str[pos] == '\"' || str[pos] == '\'') {
|
||||
if (even) {
|
||||
//quoted text
|
||||
output.push_back(str.substr(next, pos - next));
|
||||
output.emplace_back(str.substr(next, pos - next));
|
||||
even = 0;
|
||||
} else {
|
||||
//non quoted text
|
||||
|
@ -439,7 +439,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) {
|
||||
// Just reactivate that one.
|
||||
it->start = address;
|
||||
it->size = size;
|
||||
activeModuleEnds.insert(std::make_pair(it->start + it->size, *it));
|
||||
activeModuleEnds.emplace(it->start + it->size, *it);
|
||||
activeNeedUpdate_ = true;
|
||||
return;
|
||||
}
|
||||
@ -452,7 +452,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) {
|
||||
mod.index = (int)modules.size() + 1;
|
||||
|
||||
modules.push_back(mod);
|
||||
activeModuleEnds.insert(std::make_pair(mod.start + mod.size, mod));
|
||||
activeModuleEnds.emplace(mod.start + mod.size, mod);
|
||||
activeNeedUpdate_ = true;
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI
|
||||
auto active = activeFunctions.find(address);
|
||||
if (active != activeFunctions.end() && active->second.module == moduleIndex) {
|
||||
activeFunctions.erase(active);
|
||||
activeFunctions.insert(std::make_pair(address, existing->second));
|
||||
activeFunctions.emplace(address, existing->second);
|
||||
}
|
||||
} else {
|
||||
FunctionEntry func;
|
||||
@ -570,7 +570,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI
|
||||
functions[symbolKey] = func;
|
||||
|
||||
if (IsModuleActive(moduleIndex)) {
|
||||
activeFunctions.insert(std::make_pair(address, func));
|
||||
activeFunctions.emplace(address, func);
|
||||
}
|
||||
}
|
||||
|
||||
@ -716,27 +716,27 @@ void SymbolMap::UpdateActiveSymbols() {
|
||||
for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
|
||||
const auto mod = activeModuleIndexes.find(it->second.module);
|
||||
if (it->second.module == 0) {
|
||||
activeFunctions.insert(std::make_pair(it->second.start, it->second));
|
||||
activeFunctions.emplace(it->second.start, it->second);
|
||||
} else if (mod != activeModuleIndexes.end()) {
|
||||
activeFunctions.insert(std::make_pair(mod->second + it->second.start, it->second));
|
||||
activeFunctions.emplace(mod->second + it->second.start, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = labels.begin(), end = labels.end(); it != end; ++it) {
|
||||
const auto mod = activeModuleIndexes.find(it->second.module);
|
||||
if (it->second.module == 0) {
|
||||
activeLabels.insert(std::make_pair(it->second.addr, it->second));
|
||||
activeLabels.emplace(it->second.addr, it->second);
|
||||
} else if (mod != activeModuleIndexes.end()) {
|
||||
activeLabels.insert(std::make_pair(mod->second + it->second.addr, it->second));
|
||||
activeLabels.emplace(mod->second + it->second.addr, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = data.begin(), end = data.end(); it != end; ++it) {
|
||||
const auto mod = activeModuleIndexes.find(it->second.module);
|
||||
if (it->second.module == 0) {
|
||||
activeData.insert(std::make_pair(it->second.start, it->second));
|
||||
activeData.emplace(it->second.start, it->second);
|
||||
} else if (mod != activeModuleIndexes.end()) {
|
||||
activeData.insert(std::make_pair(mod->second + it->second.start, it->second));
|
||||
activeData.emplace(mod->second + it->second.start, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -757,7 +757,7 @@ bool SymbolMap::SetFunctionSize(u32 startAddress, u32 newSize) {
|
||||
if (func != functions.end()) {
|
||||
func->second.size = newSize;
|
||||
activeFunctions.erase(funcInfo);
|
||||
activeFunctions.insert(std::make_pair(startAddress, func->second));
|
||||
activeFunctions.emplace(startAddress, func->second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) {
|
||||
auto active = activeLabels.find(address);
|
||||
if (active != activeLabels.end() && active->second.module == moduleIndex) {
|
||||
activeLabels.erase(active);
|
||||
activeLabels.insert(std::make_pair(address, label));
|
||||
activeLabels.emplace(address, label);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -840,7 +840,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) {
|
||||
|
||||
labels[symbolKey] = label;
|
||||
if (IsModuleActive(moduleIndex)) {
|
||||
activeLabels.insert(std::make_pair(address, label));
|
||||
activeLabels.emplace(address, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -864,7 +864,7 @@ void SymbolMap::SetLabelName(const char* name, u32 address) {
|
||||
auto active = activeLabels.find(address);
|
||||
if (active != activeLabels.end() && active->second.module == label->second.module) {
|
||||
activeLabels.erase(active);
|
||||
activeLabels.insert(std::make_pair(address, label->second));
|
||||
activeLabels.emplace(address, label->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -947,7 +947,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) {
|
||||
auto active = activeData.find(address);
|
||||
if (active != activeData.end() && active->second.module == moduleIndex) {
|
||||
activeData.erase(active);
|
||||
activeData.insert(std::make_pair(address, existing->second));
|
||||
activeData.emplace(address, existing->second);
|
||||
}
|
||||
} else {
|
||||
DataEntry entry;
|
||||
@ -958,7 +958,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) {
|
||||
|
||||
data[symbolKey] = entry;
|
||||
if (IsModuleActive(moduleIndex)) {
|
||||
activeData.insert(std::make_pair(address, entry));
|
||||
activeData.emplace(address, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1328,7 +1328,7 @@ void sendChat(std::string chatString) {
|
||||
std::string name = g_Config.sNickName;
|
||||
|
||||
std::lock_guard<std::mutex> guard(chatLogLock);
|
||||
chatLog.push_back(name.substr(0, 8) + ": " + chat.message);
|
||||
chatLog.emplace_back(name.substr(0, 8) + ": " + chat.message);
|
||||
chatMessageGeneration++;
|
||||
}
|
||||
}
|
||||
|
@ -2007,7 +2007,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID)
|
||||
__KernelResumeThreadFromWait(waitingThreadID, freedAddress);
|
||||
|
||||
// Gotta watch the thread to quit as well, since they've allocated now.
|
||||
tlsplThreadEndChecks.insert(std::make_pair(waitingThreadID, uid));
|
||||
tlsplThreadEndChecks.emplace(waitingThreadID, uid);
|
||||
|
||||
// No need to continue or free it, we're done.
|
||||
return 0;
|
||||
@ -2234,7 +2234,7 @@ int sceKernelGetTlsAddr(SceUID uid) {
|
||||
if (allocBlock != -1)
|
||||
{
|
||||
tls->usage[allocBlock] = threadID;
|
||||
tlsplThreadEndChecks.insert(std::make_pair(threadID, uid));
|
||||
tlsplThreadEndChecks.emplace(threadID, uid);
|
||||
--tls->ntls.freeBlocks;
|
||||
needsClear = true;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ static void __KernelMutexAcquireLock(PSPMutex *mutex, int count, SceUID thread)
|
||||
_dbg_assert_msg_((*iter).second != mutex->GetUID(), "Thread %d / mutex %d wasn't removed from mutexHeldLocks properly.", thread, mutex->GetUID());
|
||||
#endif
|
||||
|
||||
mutexHeldLocks.insert(std::make_pair(thread, mutex->GetUID()));
|
||||
mutexHeldLocks.emplace(thread, mutex->GetUID());
|
||||
|
||||
mutex->nm.lockLevel = count;
|
||||
mutex->nm.lockThread = thread;
|
||||
|
@ -230,7 +230,7 @@ public:
|
||||
MipsCallManager() : idGen_(0) {}
|
||||
u32 add(MipsCall *call) {
|
||||
u32 id = genId();
|
||||
calls_.insert(std::pair<int, MipsCall *>(id, call));
|
||||
calls_.emplace(id, call);
|
||||
return id;
|
||||
}
|
||||
MipsCall *get(u32 id) {
|
||||
|
@ -265,7 +265,7 @@ void __DisplayListenVblank(VblankCallback callback) {
|
||||
|
||||
void __DisplayListenFlip(FlipCallback callback, void *userdata) {
|
||||
std::lock_guard<std::mutex> guard(listenersLock);
|
||||
flipListeners.push_back(std::make_pair(callback, userdata));
|
||||
flipListeners.emplace_back(callback, userdata);
|
||||
}
|
||||
|
||||
void __DisplayForgetFlip(FlipCallback callback, void *userdata) {
|
||||
|
@ -198,7 +198,7 @@ void JitBlockCache::ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, cons
|
||||
// Make binary searches and stuff work ok
|
||||
b.normalEntry = codePtr;
|
||||
b.checkedEntry = codePtr;
|
||||
proxyBlockMap_.insert(std::make_pair(startAddress, num_blocks_));
|
||||
proxyBlockMap_.emplace(startAddress, num_blocks_);
|
||||
AddBlockMap(num_blocks_);
|
||||
|
||||
num_blocks_++; //commit the current block
|
||||
@ -253,7 +253,7 @@ void JitBlockCache::FinalizeBlock(int block_num, bool block_link) {
|
||||
if (block_link) {
|
||||
for (int i = 0; i < MAX_JIT_BLOCK_EXITS; i++) {
|
||||
if (b.exitAddress[i] != INVALID_EXIT) {
|
||||
links_to_.insert(std::make_pair(b.exitAddress[i], block_num));
|
||||
links_to_.emplace(b.exitAddress[i], block_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ namespace MIPSAnalyst {
|
||||
for (auto iter = functions.begin(); iter != functions.end(); iter++) {
|
||||
AnalyzedFunction &f = *iter;
|
||||
if (f.hasHash && f.size > 16) {
|
||||
hashToFunction.insert(std::make_pair(f.hash, &f));
|
||||
hashToFunction.emplace(f.hash, &f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
|
||||
// Populate the default setting value.
|
||||
std::string section = StringFromFormat("%sSettingValue%d", info.section.c_str(), i + 1);
|
||||
if (!setting.name.empty() && g_Config.mPostShaderSetting.find(section) == g_Config.mPostShaderSetting.end()) {
|
||||
g_Config.mPostShaderSetting.insert(std::pair<std::string, float>(section, setting.value));
|
||||
g_Config.mPostShaderSetting.emplace(section, setting.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ void AddAddressBreakpoint(u32 addr, bool temp) {
|
||||
} else {
|
||||
// Remove the temporary marking.
|
||||
breakPCsTemp.erase(addr);
|
||||
breakPCs.insert(std::make_pair(addr, BreakpointInfo{}));
|
||||
breakPCs.emplace(addr, BreakpointInfo{});
|
||||
}
|
||||
|
||||
breakPCsCount = breakPCs.size();
|
||||
|
@ -219,9 +219,9 @@ bool SetRestrictPrims(const char *rule) {
|
||||
// If there's nothing yet, add everything else.
|
||||
if (updated.empty()) {
|
||||
if (range.first > 0)
|
||||
updated.push_back(std::make_pair(0, range.first - 1));
|
||||
updated.emplace_back(0, range.first - 1);
|
||||
if (range.second < MAX_PRIMS)
|
||||
updated.push_back(std::make_pair(range.second + 1, MAX_PRIMS));
|
||||
updated.emplace_back(range.second + 1, MAX_PRIMS);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ bool SetRestrictPrims(const char *rule) {
|
||||
// We're slicing a hole in this subrange.
|
||||
int next = sub.second;
|
||||
sub.second = range.first - 1;
|
||||
updated.push_back(std::make_pair(range.second + 1, next));
|
||||
updated.emplace_back(range.second + 1, next);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ void ShaderManagerGLES::Load(const Path &filename) {
|
||||
if (!f.ReadArray(&fsid, 1)) {
|
||||
return;
|
||||
}
|
||||
diskCachePending_.link.push_back(std::make_pair(vsid, fsid));
|
||||
diskCachePending_.link.emplace_back(vsid, fsid);
|
||||
}
|
||||
|
||||
// Actual compilation happens in ContinuePrecompile(), called by GPU_GLES's IsReady.
|
||||
|
@ -767,11 +767,11 @@ std::vector<u32> CtrlMemView::searchString(const std::string &searchQuery) {
|
||||
return searchResAddrs;
|
||||
|
||||
std::vector<std::pair<u32, u32>> memoryAreas;
|
||||
memoryAreas.push_back(std::pair<u32, u32>(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()));
|
||||
memoryAreas.reserve(3);
|
||||
memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd());
|
||||
// Ignore the video memory mirrors.
|
||||
memoryAreas.push_back(std::pair<u32, u32>(PSP_GetVidMemBase(), 0x04200000));
|
||||
memoryAreas.push_back(std::pair<u32, u32>(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()));
|
||||
memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000);
|
||||
memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd());
|
||||
|
||||
for (const auto &area : memoryAreas) {
|
||||
const u32 segmentStart = area.first;
|
||||
@ -824,9 +824,9 @@ void CtrlMemView::search(bool continueSearch)
|
||||
std::vector<std::pair<u32, u32>> memoryAreas;
|
||||
memoryAreas.reserve(3);
|
||||
// Ignore the video memory mirrors.
|
||||
memoryAreas.push_back(std::pair<u32,u32>(PSP_GetVidMemBase(), 0x04200000));
|
||||
memoryAreas.push_back(std::pair<u32,u32>(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()));
|
||||
memoryAreas.push_back(std::pair<u32, u32>(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()));
|
||||
memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000);
|
||||
memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd());
|
||||
memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd());
|
||||
|
||||
searching = true;
|
||||
redraw(); // so the cursor is disabled
|
||||
|
@ -144,7 +144,7 @@ namespace W32Util
|
||||
files.push_back(directory);
|
||||
} else {
|
||||
while (*temp) {
|
||||
files.push_back(directory + "\\" + ConvertWStringToUTF8(temp));
|
||||
files.emplace_back(directory + "\\" + ConvertWStringToUTF8(temp));
|
||||
temp += wcslen(temp) + 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user