Skip to content

Commit ccc15cd

Browse files
[lldb] Avoid repeated hash lookups (NFC) (#113412)
1 parent 5f0a628 commit ccc15cd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
461461

462462
if (reg_num != LLDB_INVALID_REGNUM &&
463463
generic_regnum != LLDB_REGNUM_GENERIC_SP) {
464-
if (m_pushed_regs.find(reg_num) == m_pushed_regs.end()) {
465-
m_pushed_regs[reg_num] = addr;
464+
if (m_pushed_regs.try_emplace(reg_num, addr).second) {
466465
const int32_t offset = addr - m_initial_sp;
467466
m_curr_row->SetRegisterLocationToAtCFAPlusOffset(reg_num, offset,
468467
/*can_replace=*/true);
@@ -608,8 +607,8 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
608607
generic_regnum != LLDB_REGNUM_GENERIC_SP) {
609608
switch (context.GetInfoType()) {
610609
case EmulateInstruction::eInfoTypeAddress:
611-
if (m_pushed_regs.find(reg_num) != m_pushed_regs.end() &&
612-
context.info.address == m_pushed_regs[reg_num]) {
610+
if (auto it = m_pushed_regs.find(reg_num);
611+
it != m_pushed_regs.end() && context.info.address == it->second) {
613612
m_curr_row->SetRegisterLocationToSame(reg_num,
614613
false /*must_replace*/);
615614
m_curr_row_modified = true;

0 commit comments

Comments
 (0)