[ icewm-Bugs-3469478 ] Improve implementation of constructors
SourceForge.net <[email protected]> Thu, 05 Jan 2012 05:30:19 -0800
| Newsgroups | gmane.comp.window-managers.icewm.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #3469478, was opened at 2012-01-04 09:18 Message generated for change (Comment added) made by elfring You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100031&aid=3469478&group_id=31 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: icewm-1.3 Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Markus Elfring (elfring) Assigned to: Nobody/Anonymous (nobody) Summary: Improve implementation of constructors Initial Comment: I have noticed that some assignments are used in the constructor bodies. Examples: http://icewm.cvs.sourceforge.net/viewvc/icewm/icewm-1.2/src/ywindow.cc?revision=1.54&view=markup http://icewm.cvs.sourceforge.net/viewvc/icewm/icewm-1.2/src/yapp.cc?revision=1.59&view=markup http://icewm.cvs.sourceforge.net/viewvc/icewm/icewm-1.2/src/ytimer.cc?revision=1.2&view=markup 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.codeguru.com/cpp/tic/tic0145.shtml http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=15&rl=1 http://goingware.com/tips/parameters/membervars.html ---------------------------------------------------------------------- >Comment By: Markus Elfring (elfring) Date: 2012-01-05 05:30 Message: Would you also like to consider any adjustments for the initialisation of pointer member variables? Update candidates: - fMotion = new XMotionEvent; - fDocked = new YXEmbedClient(this, this, win); - cpu = new int *[taskBarCPUSamples]; - fUpdateTimer = new YTimer(taskBarCPUDelay); - clockTimer = new YTimer(1000); - ppp_in = new long[taskBarNetSamples]; - ppp_out = new long[taskBarNetSamples]; - fUpdateTimer = new YTimer(); - tray = new SysTray(); - fClientContainer = new YClientContainer(this, this); - fTitleBar = new YFrameTitleBar(this, this); - Other constructors: TextView, HTextView, IceSame, AboutDlg, CtrlAltDelete How do you think about to reuse the class "std::unique_ptr"? http://en.wikipedia.org/wiki/Smart_pointer#C.2B.2B_Smart_Pointers ---------------------------------------------------------------------- Comment By: Eduard Bloch (thefirstone) Date: 2012-01-05 03:53 Message: In theory, you are right. In practice... seriously, WTF? Every normal C++ compiler from the last decade should be able to optimize trivial assignment lists as needed. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100031&aid=3469478&group_id=31 ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox