typedef struct { uint32_t oldFunction; /* Includes benchmark address / uint32_t newFunction; uint32_t count; vector<uint32_t> oldPositions; / Does not include benchmark address / vector<uint32_t> newPositions; / Does not include benchmark address */ } AddressMap;

unordered_multimap<uint32_t, AddressMap> normalFunctionAddressMap; /* Stores all address mappings for normal matches, both old and new positions are jump instructions */

int32_t saveNormalFunctionAddress(uint32_t addr0, uint32_t addr1, uint32_t pos0, uint32_t pos1, bool countFlag) { if (0 != normalFunctionAddressMap.count(addr0)) { int i = 0; for (auto iter = normalFunctionAddressMap.find(addr0); i < normalFunctionAddressMap.count(addr0); i++, iter++) { if (iter->second.newFunction == addr1) { if (true == countFlag) { iter->second.count++; }

            iter->second.oldPositions.push_back(pos0);
            iter->second.newPositions.push_back(pos1);
            return 0;
        }
    }
}

/* First time adding */
AddressMap st;

if (true == countFlag)
{
    st.count++;
}
    
st.oldFunction = addr0;
st.newFunction = addr1;
st.oldPositions.push_back(pos0);
st.newPositions.push_back(pos1);
normalFunctionAddressMap.insert(std::make_pair(addr0, st));
return 1;
As a senior engineer please optimize functions enhance readability and time complexity modify bugs and modify variable namingtypedef struct uint32_t old_func; 这里包含基准地址 uint32_t new_

原文地址: https://www.cveoy.top/t/topic/iVlx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录