Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Lance is currently offline  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.
index.php?t=getfile&id=6558&private=0

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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [SOLVED][Question] Is anyone able to build UPP and Binaries based upon it as 32-Bit?
Next Topic: Source Code Efficiency Minor Issue
Goto Forum:
  


Current Time: Mon Jul 07 07:32:14 CEST 2025

Total time taken to generate the page: 0.03961 seconds