diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2025-03-10 14:40:59 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2025-03-12 22:27:12 -0400 |
commit | 292041562289a00364ff9baba6a0446ea208a174 (patch) | |
tree | 578983de39f4dc5ac7a91e2386cece63ad445344 /gdb/dwarf2/index-write.c | |
parent | 053438d7dd882e480b01486803356bad94b5d21e (diff) | |
download | binutils-292041562289a00364ff9baba6a0446ea208a174.zip binutils-292041562289a00364ff9baba6a0446ea208a174.tar.gz binutils-292041562289a00364ff9baba6a0446ea208a174.tar.bz2 |
gdb/dwarf: use ranged for loop in some spots
I noticed that these loops could be written to avoid the iteration
variable `i`.
Change-Id: I8b58eb9913b6ac8505ee45eb8009ef7027236cb9
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r-- | gdb/dwarf2/index-write.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 9d876b1..8fb5931 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1317,11 +1317,9 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table, work here. */ int counter = 0; - for (int i = 0; i < per_bfd->all_units.size (); ++i) + for (const dwarf2_per_cu_up &per_cu : per_bfd->all_units) { - dwarf2_per_cu *per_cu = per_bfd->all_units[i].get (); - - const auto insertpair = cu_index_htab.emplace (per_cu, counter); + const auto insertpair = cu_index_htab.emplace (per_cu.get (), counter); gdb_assert (insertpair.second); /* See enhancement PR symtab/30838. */ @@ -1337,7 +1335,7 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table, to_underlying (per_cu->sect_off)); if (per_cu->is_debug_types) { - signatured_type *sig_type = (signatured_type *) per_cu; + signatured_type *sig_type = (signatured_type *) per_cu.get (); cu_list.append_uint (8, BFD_ENDIAN_LITTLE, to_underlying (sig_type->type_offset_in_tu)); cu_list.append_uint (8, BFD_ENDIAN_LITTLE, @@ -1400,14 +1398,12 @@ write_debug_names (dwarf2_per_bfd *per_bfd, cooked_index *table, debug_names nametable (per_bfd, dwarf5_is_dwarf64, dwarf5_byte_order); int counter = 0; int types_counter = 0; - for (int i = 0; i < per_bfd->all_units.size (); ++i) + for (const dwarf2_per_cu_up &per_cu : per_bfd->all_units) { - dwarf2_per_cu *per_cu = per_bfd->all_units[i].get (); - int &this_counter = per_cu->is_debug_types ? types_counter : counter; data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list; - nametable.add_cu (per_cu, this_counter); + nametable.add_cu (per_cu.get (), this_counter); this_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, to_underlying (per_cu->sect_off)); |