GNOME Bugzilla – Bug 633635
Improve implementation of constructors
Last modified: 2016-10-09 16:57:24 UTC
I have noticed that a couple of assignments are used in the constructor bodies. Examples: http://git.gnome.org/browse/gparted/tree/src/GParted_Core.cc?id=d040e4e5847905f58207e093917b6c3d36e641d7#n60 http://git.gnome.org/browse/gparted/tree/src/Dialog_Partition_Info.cc?id=d040e4e5847905f58207e093917b6c3d36e641d7#n24 http://git.gnome.org/browse/gparted/tree/src/OperationCheck.cc?id=d040e4e5847905f58207e093917b6c3d36e641d7#n23 The recommended way for performing efficient construction is to use the initialisation list. http://dietmar-kuehl.de/mirror/c++-faq/ctors.html#faq-10.6 http://cprogramming.com/tutorial/initialization-lists-c++.html http://www.eng.cam.ac.uk/help/tpl/languages/C++/Thinking_in_C++/tic0143.html http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=15&rl=1 http://goingware.com/tips/parameters/membervars.html
Thank you Markus for the examples and the links to ways to improve the GParted code. I appreciate your ability to find areas for improvement and providing background information on how such improvement works. Are you developing a patch to implement your suggested improvements?
(In reply to comment #1) I do not develop a patch for this aspect at the moment. We need to clarify a few more software design choices. The issue "Improve exception safety with smart pointers" (bug #539329) is related and will affect corresponding implementation details. Which ways would you like to go in which order?
My response can be found in: https://bugzilla.gnome.org/show_bug.cgi?id=539329#c1
Closing report as WONTFIX.
(In reply to Curtis Gedak from comment #4) I wonder about such a feedback again. Do you really reject a recommended programming approach for better C++ constructors in this software?