From fa2b038cadf17d08014e5fb75c47b5024860953e Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Sun, 30 Jul 2023 19:21:17 +0300 Subject: [PATCH] [lldb][NFC] Replace some counting loops with std::distance --- .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 5bc7a4724102..a83e46250773 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()); } } }