[gparted] Pass constant parameter by reference to load_operations() (#788814)



commit 97ce96da033358c69285dd76e5ae2ae73ac838a3
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Mar 28 16:26:00 2019 +0000

    Pass constant parameter by reference to load_operations() (#788814)
    
    It is common C++ practice to pass a constant object by reference to
    avoid constructing a duplicate object for pass by value [1].
    
    [1] How to pass objects to functions in C++?
        https://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c/2139254#2139254
    
    Bug 788814 - gparted-0.30.0/include/HBoxOperations.h:37]: performance
                 problem

 include/HBoxOperations.h | 2 +-
 src/HBoxOperations.cc    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/include/HBoxOperations.h b/include/HBoxOperations.h
index 24b7da79..2511fd5f 100644
--- a/include/HBoxOperations.h
+++ b/include/HBoxOperations.h
@@ -34,7 +34,7 @@ public:
        HBoxOperations() ;
        ~HBoxOperations() ;
 
-       void load_operations( const std::vector<Operation *> operations ) ;
+       void load_operations(const std::vector<Operation *>& operations);
        void clear() ;
 
        sigc::signal< void > signal_undo ;
diff --git a/src/HBoxOperations.cc b/src/HBoxOperations.cc
index 37f37b84..bae7000e 100644
--- a/src/HBoxOperations.cc
+++ b/src/HBoxOperations.cc
@@ -68,7 +68,8 @@ HBoxOperations::HBoxOperations()
                Gtk::Stock::CLOSE, sigc::mem_fun(*this, &HBoxOperations::on_close))));
 }
 
-void HBoxOperations::load_operations( const std::vector<Operation *> operations ) 
+
+void HBoxOperations::load_operations(const std::vector<Operation *>& operations)
 {
        liststore_operations ->clear();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]