[Ohrrpgce] SVN: teeemcee/10726 Pass strings as zstring ptrs to various functions to reduce compiled cod
subversion at HamsterRepublic.com
subversion at HamsterRepublic.com
Sun Sep 30 01:36:53 PDT 2018
teeemcee
2018-09-30 01:36:53 -0700 (Sun, 30 Sep 2018)
955
Pass strings as zstring ptrs to various functions to reduce compiled code size
Total size reduction (gengcc=1 debug=0) is:
ohrrpgce-custom: 168KB
ohrrpgce-game: 115KB
And a bit more when compiled with gengcc=0.
Pretty happy with that!
Passing a string constant as a zstring ptr is a single instruction, while
passing it as a string requires constructing and deleting an FBSTRING, which
add a lot of extra code. If the string is an expression, there's no difference.
I picked out functions which are called a lot, normally with string constants:
-debug/showerror/pop_warning/etc family
-a_append for string arrays
-RELOAD node names & paths
-config read/write functions
-readglobalstring
-multichoice/yesno/etc family
-show_help
-menu item appending functions
-etc
The main thing to watch out for when converting a function to take a zstring ptr
instead of a string is to ensure that len(s) is changed to len(*zs). len(zs)
returns sizeof(zstring ptr)!!
---
U wip/common.bi
U wip/common.rbas
U wip/common_base.bas
U wip/common_base.bi
U wip/customsubs.rbas
U wip/distribmenu.bas
U wip/game.bas
U wip/game_udts.bi
U wip/menus.bas
U wip/menus.bi
U wip/os.bi
U wip/os_unix.c
U wip/os_windows.bas
U wip/reload.bas
U wip/reload.bi
U wip/reloadext.bas
U wip/reloadext.bi
U wip/slices.bas
U wip/util.bas
U wip/util.bi
U wip/yetmore2.bas
More information about the Ohrrpgce
mailing list