[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] Proposal: Decreasing code size
From:       Heiko Schaefer <heiko () rangun ! de>
Date:       2005-09-22 16:19:26
Message-ID: 200509221819.35374.heiko () rangun ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Hi,

Kopete is growing into a huge project. And the resulting binary is growing, 
too :-)

Therefore I have a small proposal:

A c++ compiler adds a lot of unused code. One example are the automatically 
created code for the copy constructor and for the operator=.

With a small cheat you can prevent the compiler from generating this code 
without breaking binary compatibility.

Just add to every class deklaration a private copy contructor and a private 
operator=. You don't need to implement them and the compiler accepts it.

Example:

class MyClass {
	MyClass(const MyClass&);
	MyClass& operator=(const MyClass&);
public:

	// all other code here
};

If we do this on every class the resulting code size is significantly smaller.
If we really need one of this operators the compiler will produce an error.
This has even another advantage: if we really need a copy constructor or an 
operator= we know it for sure and we can write one. This improves stability, 
too.

I do this since a lot of time in all my projects (private and professional) 
and never had a disadvantage.

I know it is alot of work to add it to the existing classes, but it's worth 
it. For all new classes we should include, too.

Metta
Heiko

-- 

RANGUN-CONSULTING KARLSRUHE
     Your Linux Experts

Heiko Schaefer    | mailto:heiko@rangun.de
IT-Consultant     | http://www.rangun.de
KEYID: 0x6F5413CB |
                  | ICQ:       #287928066
Kapellenstr. 74   | Telephone: +49 (0)7 21/3 84 81 16
D-76131 Karlsruhe | Mobile:    +49 (0)1 78/7 06 32 68

[Attachment #5 (application/pgp-signature)]

_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic