Page 1 of 1

Old Schoo Coding Style

Posted: Tue Feb 10, 2026 8:25 pm
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.

Re: Old Schoo Coding Style

Posted: Wed Feb 11, 2026 12:52 am
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.

Re: Old Schoo Coding Style

Posted: Wed Feb 11, 2026 4:57 am
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.