clayborg requested changes to this revision. clayborg added a comment. This revision now requires changes to proceed.
No need for an extra map. A local C++ guru a while back told me about being able to use a comparison function with two different types if you use std::lower_bound() or std::upper_bound(). Since m_compiler_units is sorted, we can just do: static bool CompileUnitOffsetLessThan (dw_offset_t die_offset, const DWARFCompileUnitSP& cu_sp) { return die_offset < cu_sp->GetOffset(); } DWARFCompileUnitSP DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) { DWARFCompileUnitSP cu_sp; if (die_offset != DW_INVALID_OFFSET) { ParseCompileUnitHeadersIfNeeded(); // Watch out for single compile unit executable as they are pretty common const size_t num_cus = m_compile_units.size(); if (num_cus == 1) { if (m_compile_units[0]->ContainsDIEOffset(die_offset)) cu_sp = m_compile_units[0]; } else if (num_cus) { CompileUnitColl::const_iterator end_pos = m_compile_units.end(); CompileUnitColl::const_iterator begin_pos = m_compile_units.begin(); CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, die_offset, CompileUnitOffsetLessThan); if (pos != begin_pos) { --pos; if ((*pos)->ContainsDIEOffset(die_offset)) cu_sp = *pos; } } } return cu_sp; } Try out the changes and make sure they work and then switch to using the code above. http://reviews.llvm.org/D11390 _______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits