[Lldb-commits] [lldb] d87c715 - [lldb][NFC] Use early returns in ObjCLanguageRuntime::GetDescriptorIterator (#197415)
via lldb-commits
lldb-commits at lists.llvm.org
Wed May 13 04:23:05 PDT 2026
Author: Felipe de Azevedo Piovezan
Date: 2026-05-13T12:23:00+01:00
New Revision: d87c715b2cf3267b455bdf1f74d79f0a2281ce95
URL: https://github.com/llvm/llvm-project/commit/d87c715b2cf3267b455bdf1f74d79f0a2281ce95
DIFF: https://github.com/llvm/llvm-project/commit/d87c715b2cf3267b455bdf1f74d79f0a2281ce95.diff
LOG: [lldb][NFC] Use early returns in ObjCLanguageRuntime::GetDescriptorIterator (#197415)
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 29e29f59996bf..512426d0bd254 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -176,36 +176,36 @@ ObjCLanguageRuntime::GetISA(ConstString name) {
ObjCLanguageRuntime::ISAToDescriptorIterator
ObjCLanguageRuntime::GetDescriptorIterator(ConstString name) {
- ISAToDescriptorIterator end = m_isa_to_descriptor.end();
+ if (!name)
+ return m_isa_to_descriptor.end();
+
+ UpdateISAToDescriptorMap();
+
+ if (m_hash_to_isa_map.empty()) {
+ // No name hashes were provided, we need to just linearly power through
+ // the names and find a match
+ for (auto it = m_isa_to_descriptor.begin(), end = m_isa_to_descriptor.end();
+ it != end; ++it)
+ if (it->second->GetClassName() == name)
+ return it;
+ return m_isa_to_descriptor.end();
+ }
- if (name) {
- UpdateISAToDescriptorMap();
- if (m_hash_to_isa_map.empty()) {
- // No name hashes were provided, we need to just linearly power through
- // the names and find a match
- for (ISAToDescriptorIterator pos = m_isa_to_descriptor.begin();
- pos != end; ++pos) {
- if (pos->second->GetClassName() == name)
- return pos;
- }
- } else {
- // Name hashes were provided, so use them to efficiently lookup name to
- // isa/descriptor
- const uint32_t name_hash = llvm::djbHash(name.GetStringRef());
- std::pair<HashToISAIterator, HashToISAIterator> range =
- m_hash_to_isa_map.equal_range(name_hash);
- for (HashToISAIterator range_pos = range.first; range_pos != range.second;
- ++range_pos) {
- ISAToDescriptorIterator pos =
- m_isa_to_descriptor.find(range_pos->second);
- if (pos != m_isa_to_descriptor.end()) {
- if (pos->second->GetClassName() == name)
- return pos;
- }
- }
+ // Name hashes were provided, so use them to efficiently lookup name to
+ // isa/descriptor
+ const uint32_t name_hash = llvm::djbHash(name.GetStringRef());
+ std::pair<HashToISAIterator, HashToISAIterator> range =
+ m_hash_to_isa_map.equal_range(name_hash);
+ for (HashToISAIterator range_pos = range.first; range_pos != range.second;
+ ++range_pos) {
+ ISAToDescriptorIterator pos = m_isa_to_descriptor.find(range_pos->second);
+ if (pos != m_isa_to_descriptor.end()) {
+ if (pos->second->GetClassName() == name)
+ return pos;
}
}
- return end;
+
+ return m_isa_to_descriptor.end();
}
std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
More information about the lldb-commits
mailing list