Use /2 and 2* instead of >>1 and <<1 which are tricky with signed types

Today's compilers generate shift instructions to perform division and
multiplications by powers of 2 [1]. `(x >> 1)` looks straightforward enough, but
if x is signed the code will fail when x < 0. The compiler knows better: use
`x / 2`.

That's why we have code like this:

    (long)((long_u)Rows >> 1))

instead of the cleaner version that generates the same or better machine code:

    Rows / 2

[1] http://goo.gl/J4WpG7
This commit is contained in:
Felipe Oliveira Carvalho
2014-04-19 13:12:04 -03:00
committed by Thiago de Arruda
parent 9a5b3eee5f
commit db23cb05d1
6 changed files with 11 additions and 13 deletions

View File

@@ -312,7 +312,7 @@ qf_init_ext (
/*
* Get some space to modify the format string into.
*/
i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
i = 3 * FMT_PATTERNS + 4 * (int)STRLEN(efm);
for (round = FMT_PATTERNS; round > 0; )
i += (int)STRLEN(fmt_pat[--round].pattern);
#ifdef COLON_IN_FILENAME