1
0
Fork 0

Replaced inserts to emplace for compact code and improved code generation by compiler

This commit is contained in:
German Semenov 2023-09-12 19:13:40 +03:00
parent dd91e4376a
commit 11d96f1878
9 changed files with 14 additions and 14 deletions

View File

@ -73,7 +73,7 @@ bool TraceRecordManager::setTraceRecordType(duint pageAddress, TraceRecordType t
newPage.moduleIndex = ~0;
}
auto inserted = TraceRecord.insert(std::make_pair(ModHashFromAddr(pageAddress), newPage));
auto inserted = TraceRecord.emplace(ModHashFromAddr(pageAddress), newPage);
if(inserted.second == false) // we failed to insert new page into the map
{
efree(newPage.rawPtr);
@ -683,7 +683,7 @@ void TraceRecordManager::loadFromDb(JSON root)
currentPage.moduleIndex = ~0;
key = currentPage.rva;
}
TraceRecord.insert(std::make_pair(key, currentPage));
TraceRecord.emplace(key, currentPage);
}
else
efree(currentPage.rawPtr, "TraceRecordManager");

View File

@ -275,7 +275,7 @@ void ControlFlowAnalysis::Functions()
{
auto function = findFunctionStart(block, parents);
if(!function) //this happens with loops / unreferenced blocks sometimes
delayedBlocks.push_back(DelayedBlock(block, parents));
delayedBlocks.emplace_back(block, parents);
else
block->function = function;
}

View File

@ -131,11 +131,11 @@ bool BpNew(duint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE
if(Type != BPDLL && Type != BPEXCEPTION)
{
return breakpoints.insert(std::make_pair(BreakpointKey(Type, ModHashFromAddr(Address)), bp)).second;
return breakpoints.emplace(BreakpointKey(Type, ModHashFromAddr(Address)), bp).second;
}
else
{
return breakpoints.insert(std::make_pair(BreakpointKey(Type, Address), bp)).second;
return breakpoints.emplace(BreakpointKey(Type, Address), bp).second;
}
}
@ -159,7 +159,7 @@ bool BpNewDll(const char* module, bool Enable, bool Singleshot, DWORD TitanType,
// Insert new entry to the global list
EXCLUSIVE_ACQUIRE(LockBreakpoints);
return breakpoints.insert(std::make_pair(BreakpointKey(BPDLL, bp.addr), bp)).second;
return breakpoints.emplace(BreakpointKey(BPDLL, bp.addr), bp).second;
}
bool BpGet(duint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp)
@ -310,7 +310,7 @@ bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo)
_strlwr_s(temp.mod, strlen(temp.mod) + 1);
temp.addr = ModHashFromName(module1);
breakpoints.erase(i.first);
auto newItem = breakpoints.insert(std::make_pair(BreakpointKey(BPDLL, temp.addr), temp));
auto newItem = breakpoints.emplace(BreakpointKey(BPDLL, temp.addr), temp);
*newBpInfo = &newItem.first->second;
return true;
}
@ -327,7 +327,7 @@ bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo)
_strlwr_s(temp.mod, strlen(temp.mod) + 1);
temp.addr = ModHashFromName(dashPos1 + 1);
breakpoints.erase(i.first);
auto newItem = breakpoints.insert(std::make_pair(BreakpointKey(BPDLL, temp.addr), temp));
auto newItem = breakpoints.emplace(BreakpointKey(BPDLL, temp.addr), temp);
*newBpInfo = &newItem.first->second;
return true;
}

View File

@ -1021,7 +1021,7 @@ bool cbInstrGUIDFind(int argc, char* argv[])
//very likely a GUID
GUID temp;
if(CLSIDFromString(subkeyName, &temp) == S_OK)
allRegisteredGUIDs.insert(std::make_pair(temp, 0));
allRegisteredGUIDs.emplace(temp, 0);
}
}
subkeyNameLen = 40;

View File

@ -129,7 +129,7 @@ bool cbDebugRunToParty(int argc, char* argv[])
if(!BpGet(j.addr, BPMEMORY, nullptr, &bp))
{
size_t size = DbgMemGetPageSize(j.addr);
RunToUserCodeBreakpoints.push_back(std::make_pair(j.addr, size));
RunToUserCodeBreakpoints.emplace_back(j.addr, size);
SetMemoryBPXEx(j.addr, size, UE_MEMORY_EXECUTE, false, cbRunToUserCodeBreakpoint);
}
}

View File

@ -437,7 +437,7 @@ void MemUpdateMap()
{
duint start = (duint)page.mbi.BaseAddress;
duint size = (duint)page.mbi.RegionSize;
memoryPages.insert(std::make_pair(std::make_pair(start, start + size - 1), page));
memoryPages.emplace(std::make_pair(start, start + size - 1), page);
}
}

View File

@ -902,7 +902,7 @@ bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols)
// Add module to list
EXCLUSIVE_ACQUIRE(LockModules);
modinfo.insert(std::make_pair(Range(Base, Base + Size - 1), std::move(infoPtr)));
modinfo.emplace(Range(Base, Base + Size - 1), std::move(infoPtr));
EXCLUSIVE_RELEASE();
// Put labels for virtual module exports

View File

@ -56,7 +56,7 @@ bool PatchSet(duint Address, unsigned char OldByte, unsigned char NewByte)
else
{
// The entry was never found, insert it
patches.insert(std::make_pair(key, newPatch));
patches.emplace(key, newPatch);
}
return true;

View File

@ -155,7 +155,7 @@ bool varnew(const char* Name, duint Value, VAR_TYPE Type)
var.value.size = sizeof(duint);
var.value.type = VAR_UINT;
var.value.u.value = Value;
variables.insert(std::make_pair(name_, var));
variables.emplace(name_, var);
}
return true;
}