|
From: | Jean-Jacques LOHEAC |
Subject: | Re: [Help-glpk] [Fwd: glpk optimization] |
Date: | Sat, 4 Mar 2017 19:36:00 +0100 |
On Sat, 4 Mar 2017, Jean-Jacques LOHEAC wrote:
lines
./glpssx02.c: if (ssx->q == 0)
./glpssx02.c: if (ssx->p == 0)
becomes
./glpssx02.c: if (!ssx->q)
./glpssx02.c: if (!ssx->p)
If you look at the low level the processor has already load the value in
the register and the status zero is already on or off
it is not necessary to compare the value with zero. you optimize the code
and the number of cpu cycles @ low level
Do you have some reason to believe that the
compiler is too dumb to do that on its own?
Changing the source gratuitously would require another
round of tests to ensure that it was done correctly.
The choice might come down to legibility.
"if(flag)" is appropriate if flag is used as a bit.
"if(0==index)" is appropriate if index can have
multiple values and zero needs special handling.
--
Michael address@hiddenedu
"Sorry but your password must contain an uppercase letter, a number,
a haiku, a gang sign, a heiroglyph, and the blood of a virgin."
-- someeecards
[Prev in Thread] | Current Thread | [Next in Thread] |