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

List:       kde-devel
Subject:    Re: Questions on optimization/size of programs
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2000-09-15 6:51:10
[Download RAW message or body]

On Thu, 14 Sep 2000, Scott Manson wrote:

> Hello
> I am contemplating changing some const ints to enums in KWrite if
> it doesn't break b/c. 
> 
> As I was perusing code I found some const ints declared throughout various 
> source files.  My question is do we really need 32 bits to represent some of 
> the numbers or would short ints/enums be better? 
> 
> If short ints are out of question
> Could some const ints be redeclared as enums?
> 
> If I remember right the C/C++ specifications say sizeof(short) <= sizeof(int) 
> is guaranteed to be true on most platforms.
> 
> And IIRC there is a flag for gcc to "force" the compiler to use the smallest 
> bit size to represent an enum. 
> 
> Or with 32 bit architecture would this slow things down, and does the 
> compiler already "pack/optimize for size"?

Please don't do this, if it's just a size problem. Changing ints to shorts
will gain you absolutely nothing. This sort of optimization stopped being
useful back in the seventies (with memory limited embedded devices being
an exception). If it's an aesthetical thing (better looking code) or a
type safety patch (because enums are a bit more type safe than general
ints), then it would normally be OK.

Anyway, since changing the sizes of types in methods or attributes is
binary incompatible, this is a no go.

-- 

Bo Thorsen
bo@sonofthor.dk
Lahnsgade 31, st.
DK-5000 Odense C
Tlf: +45 66 11 83 85

Rule one of good programmers: anything You can do, I can do better
Rule two of good programmers: anything I can do, You can do better
The Programming Theorem: anything worth doing is worth doing over and over again

 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

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

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