03-12-2014, 06:50 PM
(This post was last modified: 03-12-2014, 06:55 PM by WannabeUser.)
So writing some code i have been reading up on how to not make it perform badly by default and came across this site http://ouns.nexuizninjaz.com/dev_quakec.html#if-chains that says:
They also mention fteqcc so i am wondering if this is something i have to worry about using gmqcc beyond that expressions that can have sideeffects (containing functions or assignments) will have them regardless of order (which i guess cant be changed as some code might rely on the sideeffects). Where i am getting is: Can i write something like if( somevar && someother && yetanother ) assuming the compiler will chose the best possible bytecode (say no possible sideeffects -> if chain - assuming that actually is the most efficient bytecode) or will it be auto performance loss for not writing if( somevar ) if( someother ) if( yetanother ) because the compiler is not clever enough or for some weird technical reason cant optimize it? The gmqcc "documentation" sadly wasnt exactly helpful so i thought it might not hurt to ask.
Somewhat related: Is there a reason to avoid switch? I have seen looooong if-else-if constructs. Is this just a preference of the authors or maybe some historical thing or is there more to it? Switch being closely related to if kinda got me curious.
Also somewhat related: Is this something i should worry about at all? I guess instantly doubting the compilers abilities to optimize stuff is kind of a bad c habit.
Quote:With default compile options (i.e. if the option -flo is not passed to the compiler), boolean expressions are evaluated fully.
They also mention fteqcc so i am wondering if this is something i have to worry about using gmqcc beyond that expressions that can have sideeffects (containing functions or assignments) will have them regardless of order (which i guess cant be changed as some code might rely on the sideeffects). Where i am getting is: Can i write something like if( somevar && someother && yetanother ) assuming the compiler will chose the best possible bytecode (say no possible sideeffects -> if chain - assuming that actually is the most efficient bytecode) or will it be auto performance loss for not writing if( somevar ) if( someother ) if( yetanother ) because the compiler is not clever enough or for some weird technical reason cant optimize it? The gmqcc "documentation" sadly wasnt exactly helpful so i thought it might not hurt to ask.
Somewhat related: Is there a reason to avoid switch? I have seen looooong if-else-if constructs. Is this just a preference of the authors or maybe some historical thing or is there more to it? Switch being closely related to if kinda got me curious.
Also somewhat related: Is this something i should worry about at all? I guess instantly doubting the compilers abilities to optimize stuff is kind of a bad c habit.