Replaced inserts to emplace for compact code and improved code generation by compiler
This commit is contained in:
		
							parent
							
								
									dd91e4376a
								
							
						
					
					
						commit
						11d96f1878
					
				| 
						 | 
					@ -73,7 +73,7 @@ bool TraceRecordManager::setTraceRecordType(duint pageAddress, TraceRecordType t
 | 
				
			||||||
                newPage.moduleIndex = ~0;
 | 
					                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
 | 
					            if(inserted.second == false) // we failed to insert new page into the map
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                efree(newPage.rawPtr);
 | 
					                efree(newPage.rawPtr);
 | 
				
			||||||
| 
						 | 
					@ -683,7 +683,7 @@ void TraceRecordManager::loadFromDb(JSON root)
 | 
				
			||||||
                    currentPage.moduleIndex = ~0;
 | 
					                    currentPage.moduleIndex = ~0;
 | 
				
			||||||
                    key = currentPage.rva;
 | 
					                    key = currentPage.rva;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                TraceRecord.insert(std::make_pair(key, currentPage));
 | 
					                TraceRecord.emplace(key, currentPage);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
                efree(currentPage.rawPtr, "TraceRecordManager");
 | 
					                efree(currentPage.rawPtr, "TraceRecordManager");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -275,7 +275,7 @@ void ControlFlowAnalysis::Functions()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                auto function = findFunctionStart(block, parents);
 | 
					                auto function = findFunctionStart(block, parents);
 | 
				
			||||||
                if(!function) //this happens with loops / unreferenced blocks sometimes
 | 
					                if(!function) //this happens with loops / unreferenced blocks sometimes
 | 
				
			||||||
                    delayedBlocks.push_back(DelayedBlock(block, parents));
 | 
					                    delayedBlocks.emplace_back(block, parents);
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                    block->function = function;
 | 
					                    block->function = function;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,11 +131,11 @@ bool BpNew(duint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(Type != BPDLL && Type != BPEXCEPTION)
 | 
					    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
 | 
					    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
 | 
					    // Insert new entry to the global list
 | 
				
			||||||
    EXCLUSIVE_ACQUIRE(LockBreakpoints);
 | 
					    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)
 | 
					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);
 | 
					                _strlwr_s(temp.mod, strlen(temp.mod) + 1);
 | 
				
			||||||
                temp.addr = ModHashFromName(module1);
 | 
					                temp.addr = ModHashFromName(module1);
 | 
				
			||||||
                breakpoints.erase(i.first);
 | 
					                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;
 | 
					                *newBpInfo = &newItem.first->second;
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -327,7 +327,7 @@ bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo)
 | 
				
			||||||
                _strlwr_s(temp.mod, strlen(temp.mod) + 1);
 | 
					                _strlwr_s(temp.mod, strlen(temp.mod) + 1);
 | 
				
			||||||
                temp.addr = ModHashFromName(dashPos1 + 1);
 | 
					                temp.addr = ModHashFromName(dashPos1 + 1);
 | 
				
			||||||
                breakpoints.erase(i.first);
 | 
					                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;
 | 
					                *newBpInfo = &newItem.first->second;
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1021,7 +1021,7 @@ bool cbInstrGUIDFind(int argc, char* argv[])
 | 
				
			||||||
                //very likely a GUID
 | 
					                //very likely a GUID
 | 
				
			||||||
                GUID temp;
 | 
					                GUID temp;
 | 
				
			||||||
                if(CLSIDFromString(subkeyName, &temp) == S_OK)
 | 
					                if(CLSIDFromString(subkeyName, &temp) == S_OK)
 | 
				
			||||||
                    allRegisteredGUIDs.insert(std::make_pair(temp, 0));
 | 
					                    allRegisteredGUIDs.emplace(temp, 0);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        subkeyNameLen = 40;
 | 
					        subkeyNameLen = 40;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -129,7 +129,7 @@ bool cbDebugRunToParty(int argc, char* argv[])
 | 
				
			||||||
                if(!BpGet(j.addr, BPMEMORY, nullptr, &bp))
 | 
					                if(!BpGet(j.addr, BPMEMORY, nullptr, &bp))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    size_t size = DbgMemGetPageSize(j.addr);
 | 
					                    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);
 | 
					                    SetMemoryBPXEx(j.addr, size, UE_MEMORY_EXECUTE, false, cbRunToUserCodeBreakpoint);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -437,7 +437,7 @@ void MemUpdateMap()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        duint start = (duint)page.mbi.BaseAddress;
 | 
					        duint start = (duint)page.mbi.BaseAddress;
 | 
				
			||||||
        duint size = (duint)page.mbi.RegionSize;
 | 
					        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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -902,7 +902,7 @@ bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Add module to list
 | 
					    // Add module to list
 | 
				
			||||||
    EXCLUSIVE_ACQUIRE(LockModules);
 | 
					    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();
 | 
					    EXCLUSIVE_RELEASE();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Put labels for virtual module exports
 | 
					    // Put labels for virtual module exports
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ bool PatchSet(duint Address, unsigned char OldByte, unsigned char NewByte)
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // The entry was never found, insert it
 | 
					        // The entry was never found, insert it
 | 
				
			||||||
        patches.insert(std::make_pair(key, newPatch));
 | 
					        patches.emplace(key, newPatch);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,7 +155,7 @@ bool varnew(const char* Name, duint Value, VAR_TYPE Type)
 | 
				
			||||||
        var.value.size = sizeof(duint);
 | 
					        var.value.size = sizeof(duint);
 | 
				
			||||||
        var.value.type = VAR_UINT;
 | 
					        var.value.type = VAR_UINT;
 | 
				
			||||||
        var.value.u.value = Value;
 | 
					        var.value.u.value = Value;
 | 
				
			||||||
        variables.insert(std::make_pair(name_, var));
 | 
					        variables.emplace(name_, var);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue