This patch better exploits short-circuit evaluation in
two 'if' tests. In every case, the 1st of 2 conditions
in each 'if' test must take place but it always proves
true with each iteration for 1 of the 'if' statements.
Thus, the 2nd condition will have to be evaluated too.
By reordering 2 tests in each 'if', we can ensure that
the 2nd condition will then be tested much less often.
Signed-off-by: Jim Warner <james.warner@comcast.net>
while (*p) {
// -1 represents a decoding error, don't encourage repositioning ...
if (0 > (clen = UTF8_tab[*p])) return col;
- if (tophysical && cnum + 1 > col) break;
+ if (cnum + 1 > col && tophysical) break;
p += clen;
tlen += clen;
- if (!tophysical && tlen > col) break;
+ if (tlen > col && !tophysical) break;
++cnum;
}
return tophysical ? tlen : cnum;