[Lldb-commits] [lldb] fa2b038 - [lldb][NFC] Replace some counting loops with std::distance
Vlad Serebrennikov via lldb-commits
lldb-commits at lists.llvm.org
Sun Jul 30 09:22:08 PDT 2023
Author: Vlad Serebrennikov
Date: 2023-07-30T19:22:02+03:00
New Revision: fa2b038cadf17d08014e5fb75c47b5024860953e
URL: https://github.com/llvm/llvm-project/commit/fa2b038cadf17d08014e5fb75c47b5024860953e
DIFF: https://github.com/llvm/llvm-project/commit/fa2b038cadf17d08014e5fb75c47b5024860953e.diff
LOG: [lldb][NFC] Replace some counting loops with std::distance
Added:
Modified:
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 5bc7a47241028d..a83e4625077350 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5361,11 +5361,8 @@ uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
num_children += cxx_record_decl->getNumBases();
}
}
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(),
- field_end = record_decl->field_end();
- field != field_end; ++field)
- ++num_children;
+ num_children += std::distance(record_decl->field_begin(),
+ record_decl->field_end());
}
break;
@@ -5576,13 +5573,8 @@ uint32_t TypeSystemClang::GetNumFields(lldb::opaque_compiler_type_t type) {
if (record_type) {
clang::RecordDecl *record_decl = record_type->getDecl();
if (record_decl) {
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(),
- field_end = record_decl->field_end();
- field != field_end; ++field)
- ++field_idx;
- count = field_idx;
+ count = std::distance(record_decl->field_begin(),
+ record_decl->field_end());
}
}
}
More information about the lldb-commits
mailing list