[dwarf-reader] Optimize speed of compare_as_decl_dies
authorDodji Seketeli <dodji@redhat.com>
Mon, 17 Jun 2019 12:26:45 +0000 (14:26 +0200)
committerDodji Seketeli <dodji@redhat.com>
Mon, 17 Jun 2019 12:56:43 +0000 (14:56 +0200)
commit133d43ad1986720ed7ffe11523936699d34f89a5
tree646b8be451d90dfc52af3b7383eb2ba835a4989e
parent23744b4b8ebb351b1d33041b0f3811b49db9b627
[dwarf-reader] Optimize speed of compare_as_decl_dies

Profiling shows that the *number of calls* to
compare_dies_string_attribute_value by compare_as_decl_dies represents
a hotspot.  That is, compare_dies_string_attribute_value itself
doesn't necessarily takes long, but it's being called "too much",
especially when compare_as_decl_dies is called for DIEs representing
classes/structs.

This patch thus reduces the calls to
compare_dies_string_attribute_value from 3 to 1 for classes/structs.

This optimization makes abidw's reading be 10% faster (from ~5min:15s
to ~ 4min:45s) on a fullblow vmlinux.  Note that abidw writting time
hasn't been yet optimized.

* src/abg-dwarf-reader.cc (die_is_class_type): Take a const
pointer to Dwarf_Die.
(compare_as_decl_dies): For classes/structs, call
compare_dies_string_attribute_value just once to compare the
DW_AT_name attribute values.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc