summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2022-01-21 17:30:05 +0000
committerDodji Seketeli <dodji@redhat.com>2022-02-24 18:33:49 +0100
commitf7239898451236b5a6dc1df14aee73940b7dfda5 (patch)
treefdbdb8fe096ef17cf2818c017e7d06cb3dc398ff
parentXML writer: improve slightly emission of top-level declarations (diff)
downloadlibabigail-f7239898451236b5a6dc1df14aee73940b7dfda5.tar.gz
libabigail-f7239898451236b5a6dc1df14aee73940b7dfda5.tar.bz2
libabigail-f7239898451236b5a6dc1df14aee73940b7dfda5.tar.xz
XML writer: do not create extra temporary referenced type shared_ptr
In the loop of write_referenced_types temporary shared_ptr objects are created. In the case of a declaration, two shared_ptrs are created. It is possible to code this so only one object is created. This is a small optimisation with no change to tests or behaviour. * src/abg-writer.cc (write_referenced_types): Create temporary shared_ptr objects within each conditional branch instead of outside the conditionals and within one of the branches. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com>
-rw-r--r--src/abg-writer.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 496f36a6..7802128d 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -2321,18 +2321,21 @@ write_referenced_types(write_context & ctxt,
2321 { 2321 {
2322 // We handle types which have declarations *and* function 2322 // We handle types which have declarations *and* function
2323 // types here. 2323 // types here.
2324 type_base_sptr t(*i, noop_deleter()); 2324 type_base* t = *i;
2325 if (!ctxt.type_is_emitted(t)) 2325 if (!ctxt.type_is_emitted(t))
2326 { 2326 {
2327 if (decl_base* d = get_type_declaration(*i)) 2327 if (decl_base* d = get_type_declaration(t))
2328 { 2328 {
2329 decl_base_sptr decl(d, noop_deleter()); 2329 decl_base_sptr decl(d, noop_deleter());
2330 write_decl_in_scope(decl, ctxt, 2330 write_decl_in_scope(decl, ctxt,
2331 indent + c.get_xml_element_indent()); 2331 indent + c.get_xml_element_indent());
2332 } 2332 }
2333 else if (function_type_sptr fn_type = is_function_type(t)) 2333 else if (function_type* f = is_function_type(t))
2334 write_function_type(fn_type, ctxt, 2334 {
2335 indent + c.get_xml_element_indent()); 2335 function_type_sptr fn_type(f, noop_deleter());
2336 write_function_type(fn_type, ctxt,
2337 indent + c.get_xml_element_indent());
2338 }
2336 else 2339 else
2337 ABG_ASSERT_NOT_REACHED; 2340 ABG_ASSERT_NOT_REACHED;
2338 } 2341 }