Home » Developing U++ » U++ Developers corner » Know what you're using. Size of some common types.
Re: Know what you're using. Size of some common types. [message #57945 is a reply to message #57944] |
Fri, 31 December 2021 20:20   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
In the spirit of previous discussion with Novo, the following minor change to CtrlCore/CtrlCore.h should decrease the sizeof(Ctrl) and that of all its derivative by 8 bytes on a 64-bit platform. While on 32-bit system there is no gain(Ctrl has been perfectly fine tuned for 32-bit platform), and there should be no penalties either.
Current code:
Top *top;
int exitcode;
Ctrl *prev, *next;
Ctrl *firstchild, *lastchild;//16
LogPos pos;//8
Rect16 rect;
Mitor<Frame> frame;//16
String info;//16
int16 caretx, carety, caretcx, caretcy;//8
byte overpaint;
Proposed change:
Top *top;
Ctrl *prev, *next;
Ctrl *firstchild, *lastchild;//16
LogPos pos;//8
Rect16 rect;
Mitor<Frame> frame;//16
String info;//16
int16 caretx, carety, caretcx, caretcy;//8
int exitcode; // move the line here
byte overpaint;
After the change, sizeof(Ctrl) is reduced from 152 bytes to 144 bytes on 64bit platform (both MSBT22x64 and CLANG64), while on 32bit platform, it remains unchanged with CLANG, but increases by 8 bytes with MSBT22. This increase is unexpected. If anybody can explain it or figure out a way to avoid it, it will be fully appreciated.
@mirek or @klugier, please consider apply the change after identifying and fixing the unexpected behavior with MSBT. The change is too simple to have potential danger and will affect all objects of Ctrl and its derivatives.

PS: By making use of MSC 32 bit flag _M_IX86, the above problem could be circumvented as follows:
...
Top *top;
#if defined(_M_IX86) // 32bit MSC compiler
int exitcode;
#endif
Ctrl *prev, *next;
Ctrl *firstchild, *lastchild;//16
LogPos pos;//8
Rect16 rect;
Mitor<Frame> frame;//16
String info;//16
int16 caretx, carety, caretcx, caretcy;//8
#if !defined(_M_IX86)
int exitcode;
#endif
byte overpaint;
bool unicode:1;
bool fullrefresh:1;
bool transparent:1;
bool visible:1;
bool enabled:1;
bool wantfocus:1;
bool initfocus:1;
bool activepopup:1;
bool editable:1;
bool modify:1;
bool ignoremouse:1;
...
-
Attachment: a.png
(Size: 11.67KB, Downloaded 526 times)
[Updated on: Fri, 31 December 2021 22:57] Report message to a moderator
|
|
|
 |
|
Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 19:33
|
 |
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 19:58
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:32
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:37
|
 |
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 21:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 02:29
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 05:17
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 20:27
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 23:49
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Wed, 29 December 2021 01:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Thu, 30 December 2021 02:39
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 19:51
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:20
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:28
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 05 January 2022 10:47
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:25
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:44
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:34
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:01
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:26
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 22:22
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Sun, 09 January 2022 20:36
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Mon, 10 January 2022 01:07
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 02:00
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 21:43
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 02:29
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Tue, 11 January 2022 13:41
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 15:19
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 17:40
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:07
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:25
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 11 May 2022 09:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Thu, 12 May 2022 08:26
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Sat, 14 May 2022 21:30
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:32
|
Goto Forum:
Current Time: Mon Jul 07 07:32:14 CEST 2025
Total time taken to generate the page: 0.03961 seconds
|