From 915042e207f5c6ecfa683360ad2b57ac3abfd58b Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 10 Mar 2015 18:41:44 +0100 Subject: [PATCH] Pass a bunch of smart pointers by reference Some smart pointers handling got high on performance profiles. I am passing those by reference here. * include/abg-fwd.h (get_member_is_static, is_member_function) (get_member_function_is_ctor, set_member_function_is_ctor) (get_member_function_is_dtor, set_member_function_is_dtor) (get_member_function_is_const, set_member_function_is_const) (get_member_function_vtable_offset) (set_member_function_vtable_offset) (get_member_function_is_virtual): Declare the smart pointer parameter of these as being passed by reference. * include/abg-ir.h (get_member_access_specifier) (get_member_is_static, get_member_access_specifier) (set_member_function_is_ctor, set_member_function_is_const) (set_member_function_vtable_offset): Likewise, for these friend declarations to the decl_base type. * src/abg-ir.cc (get_member_access_specifier) (get_member_is_static, is_member_function) (get_member_function_is_ctor, set_member_function_is_ctor) (get_member_function_is_dtor, set_member_function_is_dtor) (get_member_function_is_const, set_member_function_is_const) (get_member_function_vtable_offset) (set_member_function_vtable_offset) (get_member_function_is_virtual): In these definitions, the smart pointer parameter is passed by reference. Signed-off-by: Dodji Seketeli --- include/abg-fwd.h | 22 +++++++++++----------- include/abg-ir.h | 18 +++++++++++++++--- src/abg-ir.cc | 24 ++++++++++++------------ 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/include/abg-fwd.h b/include/abg-fwd.h index e236c9f5..8d8bfb84 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -292,7 +292,7 @@ bool get_member_is_static(const decl_base*); bool -get_member_is_static(const shared_ptr); +get_member_is_static(const shared_ptr&); void set_member_is_static(decl_base&, bool); @@ -343,63 +343,63 @@ bool is_member_function(const function_decl*); bool -is_member_function(const shared_ptr); +is_member_function(const shared_ptr&); bool get_member_function_is_ctor(const function_decl&); bool -get_member_function_is_ctor(const shared_ptr); +get_member_function_is_ctor(const shared_ptr&); void set_member_function_is_ctor(const function_decl&, bool); void -set_member_function_is_ctor(const shared_ptr, bool); +set_member_function_is_ctor(const shared_ptr&, bool); bool get_member_function_is_dtor(const function_decl&); bool -get_member_function_is_dtor(const shared_ptr); +get_member_function_is_dtor(const shared_ptr&); void set_member_function_is_dtor(function_decl&, bool); void -set_member_function_is_dtor(const shared_ptr, bool); +set_member_function_is_dtor(const shared_ptr&, bool); bool get_member_function_is_const(const function_decl&); bool -get_member_function_is_const(const shared_ptr); +get_member_function_is_const(const shared_ptr&); void set_member_function_is_const(function_decl&, bool); void -set_member_function_is_const(const shared_ptr, bool); +set_member_function_is_const(const shared_ptr&, bool); size_t get_member_function_vtable_offset(const function_decl&); size_t -get_member_function_vtable_offset(const shared_ptr); +get_member_function_vtable_offset(const shared_ptr&); void set_member_function_vtable_offset(const function_decl& f, size_t s); void -set_member_function_vtable_offset(const shared_ptr f, +set_member_function_vtable_offset(const shared_ptr &f, size_t s); bool get_member_function_is_virtual(const function_decl&); bool -get_member_function_is_virtual(const shared_ptr); +get_member_function_is_virtual(const shared_ptr&); bool get_member_function_is_virtual(const function_decl*); diff --git a/include/abg-ir.h b/include/abg-ir.h index a0fc462f..12488506 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -767,7 +767,7 @@ public: get_member_access_specifier(const decl_base& d); friend enum access_specifier - get_member_access_specifier(const decl_base_sptr d); + get_member_access_specifier(const decl_base_sptr& d); friend void set_member_access_specifier(decl_base& d, @@ -777,7 +777,7 @@ public: get_member_is_static(const decl_base& d); friend bool - get_member_is_static(const decl_base_sptr d); + get_member_is_static(const decl_base_sptr& d); friend void set_member_is_static(const decl_base_sptr& d, bool s); @@ -2644,7 +2644,7 @@ enum access_specifier get_member_access_specifier(const decl_base&); enum access_specifier -get_member_access_specifier(const decl_base_sptr); +get_member_access_specifier(const decl_base_sptr&); void set_member_access_specifier(decl_base&, @@ -2951,12 +2951,18 @@ public: friend void set_member_function_is_ctor(function_decl&, bool); + friend void + set_member_function_is_ctor(const function_decl_sptr&, bool); + friend bool get_member_function_is_dtor(const function_decl&); friend void set_member_function_is_dtor(function_decl&, bool); + friend void + set_member_function_is_dtor(const function_decl_sptr&, bool); + friend bool get_member_function_is_static(const function_decl&); @@ -2969,12 +2975,18 @@ public: friend void set_member_function_is_const(function_decl&, bool); + friend void + set_member_function_is_const(const function_decl_sptr&, bool); + friend size_t get_member_function_vtable_offset(const function_decl&); friend void set_member_function_vtable_offset(function_decl&, size_t); + friend void + set_member_function_vtable_offset(const function_decl_sptr&, size_t); + friend bool get_member_function_is_virtual(const function_decl&); diff --git a/src/abg-ir.cc b/src/abg-ir.cc index a1bc6f4e..6615cb9e 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1737,7 +1737,7 @@ get_member_access_specifier(const decl_base& d) /// /// @return the access specifier for the class member @p d. access_specifier -get_member_access_specifier(const decl_base_sptr d) +get_member_access_specifier(const decl_base_sptr& d) {return get_member_access_specifier(*d);} /// Sets the access specifier for a class member. @@ -1808,7 +1808,7 @@ get_member_is_static(const decl_base* d) /// /// @return true if the class member @p d is static, false otherwise. bool -get_member_is_static(const decl_base_sptr d) +get_member_is_static(const decl_base_sptr& d) {return get_member_is_static(*d);} /// Sets the static-ness property of a class member. @@ -1998,7 +1998,7 @@ is_member_function(const function_decl* f) /// /// @return true if @p f is a member function, false otherwise. bool -is_member_function(const function_decl_sptr f) +is_member_function(const function_decl_sptr& f) {return is_member_function(*f);} /// Test whether a member function is a constructor. @@ -2027,7 +2027,7 @@ get_member_function_is_ctor(const function_decl& f) /// /// @return true if @p f is a constructor, false otherwise. bool -get_member_function_is_ctor(const function_decl_sptr f) +get_member_function_is_ctor(const function_decl_sptr& f) {return get_member_function_is_ctor(*f);} @@ -2059,7 +2059,7 @@ set_member_function_is_ctor(function_decl& f, bool c) /// @param f the new boolean value of the is_ctor property. Is true /// if @p f is a constructor, false otherwise. void -set_member_function_is_ctor(const function_decl_sptr f, bool c) +set_member_function_is_ctor(const function_decl_sptr& f, bool c) {set_member_function_is_ctor(*f, c);} /// Test whether a member function is a destructor. @@ -2088,7 +2088,7 @@ get_member_function_is_dtor(const function_decl& f) /// /// @return true if @p f is a destructor, false otherwise. bool -get_member_function_is_dtor(const function_decl_sptr f) +get_member_function_is_dtor(const function_decl_sptr& f) {return get_member_function_is_dtor(*f);} /// Set the destructor-ness property of a member function. @@ -2117,7 +2117,7 @@ set_member_function_is_dtor(function_decl& f, bool d) /// /// @param d true if @p f is a destructor, false otherwise. void -set_member_function_is_dtor(const function_decl_sptr f, bool d) +set_member_function_is_dtor(const function_decl_sptr& f, bool d) {set_member_function_is_dtor(*f, d);} /// Test whether a member function is const. @@ -2146,7 +2146,7 @@ get_member_function_is_const(const function_decl& f) /// /// @return true if @p f is const, false otherwise. bool -get_member_function_is_const(const function_decl_sptr f) +get_member_function_is_const(const function_decl_sptr& f) {return get_member_function_is_const(*f);} /// set the const-ness property of a member function. @@ -2175,7 +2175,7 @@ set_member_function_is_const(function_decl& f, bool is_const) /// /// @param is_const the new value of the const-ness property of @p f void -set_member_function_is_const(const function_decl_sptr f, bool is_const) +set_member_function_is_const(const function_decl_sptr& f, bool is_const) {set_member_function_is_const(*f, is_const);} /// Get the vtable offset of a member function. @@ -2204,7 +2204,7 @@ get_member_function_vtable_offset(const function_decl& f) /// /// @return the vtable offset of @p f. size_t -get_member_function_vtable_offset(const function_decl_sptr f) +get_member_function_vtable_offset(const function_decl_sptr& f) {return get_member_function_vtable_offset(*f);} /// Set the vtable offset of a member function. @@ -2232,7 +2232,7 @@ set_member_function_vtable_offset(function_decl& f, size_t s) /// /// @param s the new vtable offset. void -set_member_function_vtable_offset(const function_decl_sptr f, size_t s) +set_member_function_vtable_offset(const function_decl_sptr& f, size_t s) {return set_member_function_vtable_offset(*f, s);} /// Test if a given member function is virtual. @@ -2261,7 +2261,7 @@ get_member_function_is_virtual(const function_decl& f) /// /// @return true iff a @p mem_fn is virtual. bool -get_member_function_is_virtual(const function_decl_sptr mem_fn) +get_member_function_is_virtual(const function_decl_sptr& mem_fn) {return mem_fn ? get_member_function_is_virtual(*mem_fn) : false;} /// Test if a given member function is virtual.