I had an interesting thing happen today. I have a program that is around 400 lines with a datasection containing about 30k or so of graphics. The structure of the program was all inline code with If-ElseIf-ElseIf-ElseIf-Endif to choose which code to run based on the mode found in the program parameters. It compiled to around 147k for the exe size. Once I was happy with the way the code ran, I restructured the program so that each of the code sections was in its own procedure and all the If-ElseIf block did was choose which procedure to run and then end. The code itself changed very little, nothing significant was removed. But after the restructure, the compiled exe size went down to 115k from 147.
Has anyone else noticed similar? And if this is something to be expected, can someone shed some light on why? I'm flummoxed as to why this would be.
Procedures cut exe size?
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Procedures cut exe size?
BERESHEIT
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Procedures cut exe size?
Without seeing the code, it sounds like the procedures are replacing many repetitions of (small?) blocks of code, and therefore obviously the executable would become smaller. But only you know if that's the case, since you can see the code.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Procedures cut exe size?
No, the blocks only execute once. There's loops in them but the loops are in the procs too.
BERESHEIT
Re: Procedures cut exe size?
That's interesting. I'll have to do my own test sometime and see what results I get. I usually use procedures anyway. But if what you are saying works for all code, then that could be helpful.
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.