Old Schoo Coding Style

Just starting out? Need help? Post your questions and find answers here.
User avatar
syntonica
User
User
Posts: 26
Joined: Fri Feb 06, 2026 10:34 pm

Old Schoo Coding Style

Post by syntonica »

I often see expressions like thiese in example code:

Code: Select all

Event = Event()
EventWindow = EventWindow()
...
This was an old trick for getting compilers to save values in registers rather than re-evaluating the function each time.

Is this still suggested with the PB compiler? Or, is this just old-school style?

Which brings me to my point of the question: how optimizig is the compiler? With modern GCC/Clang/MSVC, "stupid" compiler tricks are no longer necessary. The compilers just know how to translate into the most efficient machine code, down to out-of-order execution.
User avatar
idle
Always Here
Always Here
Posts: 6197
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Old Schoo Coding Style

Post by idle »

Depends on what your doing.
You can use Bindevent to call a procedure or use ev = event() which I asume wraps a fifo list.

The c backend optimizer level is O2

The asm backend has no optimization as such so you still need to consider things

I have libs that run the same speed with asm or c backends which I assume is due to source optimization and branch elimination. I could likely redo it for the c backend without the source optimization and get the same result from the c optimization parse, though when your doing libs and you want them to run on both backends and all pb targets you have to apply source optimization the best you can and that's generally being cognizant of structures size alignment memory access branch elimination and how to get free cycles from out of order execution at branches.
User avatar
mk-soft
Always Here
Always Here
Posts: 6579
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Old Schoo Coding Style

Post by mk-soft »

Without variables and directly with Select : Case : EndSelect.
So the compiler can link it optimized and without assigning it to a variable.
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Post Reply