From 91840ee38a1114bc02120935bf73dd5acda3b062 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 12 Oct 2020 15:53:16 -0600 Subject: Simplify add_target_sections_of_objfile Now that target_section_table uses std::vector, add_target_sections_of_objfile does not need to loop twice. This patch simplifies this code to have just a single loop. Also, the passed-in objfile can never be NULL, so this changes this function to assert that. gdb/ChangeLog 2020-10-12 Tom Tromey * exec.c (add_target_sections_of_objfile): Simplify. --- gdb/exec.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'gdb/exec.c') diff --git a/gdb/exec.c b/gdb/exec.c index d4b9b7b..43385fe 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -661,26 +661,14 @@ add_target_sections_of_objfile (struct objfile *objfile) { struct target_section_table *table = current_target_sections; struct obj_section *osect; - unsigned count = 0; - if (objfile == NULL) - return; + gdb_assert (objfile != nullptr); /* Compute the number of sections to add. */ ALL_OBJFILE_OSECTIONS (objfile, osect) { if (bfd_section_size (osect->the_bfd_section) == 0) continue; - count++; - } - - if (count == 0) - return; - - ALL_OBJFILE_OSECTIONS (objfile, osect) - { - if (bfd_section_size (osect->the_bfd_section) == 0) - continue; table->sections.emplace_back (); target_section &ts = table->sections.back (); -- cgit v1.1