Pass some more parameters in reference
authorDodji Seketeli <dodji@redhat.com>
Thu, 15 Oct 2015 07:42:54 +0000 (09:42 +0200)
committerDodji Seketeli <dodji@redhat.com>
Thu, 15 Oct 2015 11:50:55 +0000 (13:50 +0200)
Profiling as shown that we might gain some precious cycles by passing
some well chosen parameters by reference.

* include/abg-ir.h (operator==): For the type_base_sptr and
decl_base_sptr overloads, pass the parameters by reference.
({var,function}_decl::{set,get}_symbol): Pass the elf_symbol_ptr
by reference.
* src/abg-ir.cc (operator==): For the type_base_sptr and
decl_base_sptr overloads, pass the parameters by reference, now in
the definition.
({var,function}_decl::{set,get}_symbol): Pass the elf_symbol_ptr
by reference, now in the definition.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-ir.h
src/abg-ir.cc

index 412536d..8c56709 100644 (file)
@@ -1055,10 +1055,10 @@ public:
 };// end class decl_base
 
 bool
-operator==(const decl_base_sptr, const decl_base_sptr);
+operator==(const decl_base_sptr&, const decl_base_sptr&);
 
 bool
-operator==(const type_base_sptr, const type_base_sptr);
+operator==(const type_base_sptr&, const type_base_sptr&);
 
 std::ostream&
 operator<<(std::ostream&, decl_base::visibility);
@@ -1998,9 +1998,9 @@ public:
   set_binding(binding b);
 
   void
-  set_symbol(elf_symbol_sptr sym);
+  set_symbol(const elf_symbol_sptr& sym);
 
-  elf_symbol_sptr
+  const elf_symbol_sptr&
   get_symbol() const;
 
   var_decl_sptr
@@ -2114,9 +2114,9 @@ public:
   set_type(function_type_sptr fn_type);
 
   void
-  set_symbol(elf_symbol_sptr sym);
+  set_symbol(const elf_symbol_sptr& sym);
 
-  elf_symbol_sptr
+  const elf_symbol_sptr&
   get_symbol() const;
 
   bool
index 100bd30..eb41314 100644 (file)
@@ -2461,7 +2461,7 @@ operator<<(std::ostream& o, decl_base::binding b)
 /// @return true if the decl_base pointed to by the shared_ptrs are
 /// equal, false otherwise.
 bool
-operator==(const decl_base_sptr l, const decl_base_sptr r)
+operator==(const decl_base_sptr& l, const decl_base_sptr& r)
 {
   if (l.get() == r.get())
     return true;
@@ -2483,7 +2483,7 @@ operator==(const decl_base_sptr l, const decl_base_sptr r)
 /// @return true if the type_base pointed to by the shared_ptrs are
 /// equal, false otherwise.
 bool
-operator==(const type_base_sptr l, const type_base_sptr r)
+operator==(const type_base_sptr& l, const type_base_sptr& r)
 {
     if (l.get() == r.get())
     return true;
@@ -8430,7 +8430,7 @@ var_decl::set_binding(decl_base::binding b)
 ///
 /// @param sym the new ELF symbol for this variable decl.
 void
-var_decl::set_symbol(elf_symbol_sptr sym)
+var_decl::set_symbol(const elf_symbol_sptr& sym)
 {priv_->symbol_ = sym;}
 
 /// Gets the the underlying ELF symbol for the current variable,
@@ -8440,7 +8440,7 @@ var_decl::set_symbol(elf_symbol_sptr sym)
 ///
 /// @return sym the underlying ELF symbol for this variable decl, if
 /// one exists.
-elf_symbol_sptr
+const elf_symbol_sptr&
 var_decl::get_symbol() const
 {return priv_->symbol_;}
 
@@ -9505,7 +9505,7 @@ function_decl::set_type(shared_ptr<function_type> fn_type)
 ///
 /// @param sym the new ELF symbol for this function decl.
 void
-function_decl::set_symbol(elf_symbol_sptr sym)
+function_decl::set_symbol(const elf_symbol_sptr& sym)
 {priv_->symbol_ = sym;}
 
 /// Gets the the underlying ELF symbol for the current variable,
@@ -9515,7 +9515,7 @@ function_decl::set_symbol(elf_symbol_sptr sym)
 ///
 /// @return sym the underlying ELF symbol for this function decl, if
 /// one exists.
-elf_symbol_sptr
+const elf_symbol_sptr&
 function_decl::get_symbol() const
 {return priv_->symbol_;}