[22/38] Minor simplification in abbrev_table::read

Message ID 20200123005710.7978-23-tom@tromey.com
State New
Headers show
Series
  • Start reorganization of DWARF code
Related show

Commit Message

Tom Tromey Jan. 23, 2020, 12:56 a.m.
abbrev_table::read increments cur_abbrev->num_attrs in the inner loop,
but there's no need to do this, as the information is already stored
in the temporary vector.

2020-01-22  Tom Tromey  <tom@tromey.com>

	* dwarf2/abbrev.c (abbrev_table::read): Simplify.

Change-Id: I765f12850ffa1c6066e884bb22c94468d1abdba4
---
 gdb/ChangeLog       | 4 ++++
 gdb/dwarf2/abbrev.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.17.2

Patch

diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
index f843e32d950..59ff138b33d 100644
--- a/gdb/dwarf2/abbrev.c
+++ b/gdb/dwarf2/abbrev.c
@@ -162,9 +162,9 @@  abbrev_table::read (struct objfile *objfile,
 	  cur_attr.name = (enum dwarf_attribute) abbrev_name;
 	  cur_attr.form = (enum dwarf_form) abbrev_form;
 	  cur_attr.implicit_const = implicit_const;
-	  ++cur_abbrev->num_attrs;
 	}
 
+      cur_abbrev->num_attrs = cur_attrs.size ();
       cur_abbrev->attrs =
 	XOBNEWVEC (&abbrev_table->m_abbrev_obstack, struct attr_abbrev,
 		   cur_abbrev->num_attrs);