Mail Archives: djgpp/1997/09/24/10:58:01
On Mon, 22 Sep 1997, Paul Shirley wrote:
> >It is true that for some architectures, ints are faster than shorts.
> >However, when portability is an issue, IMHO, use shorts and don't look
> >back.
>
> The net result is for a 2 byte data saving you pay much more in extra
> code and potentially reduced cache effectiveness.
My advice was for the cases where portability is an issue, not data
saving. I do agree that using shorts for the purpose of saving data
is a bad idea.
> gcc will optimise away most of this, even so we are seeing measurable
> speedups from switching shorts->ints in R3000 code.
Can you post some measurements? How much slower is the code that uses
shorts. (Please note that I did advise against using shorts as the index
in a tight loop, since there portability is usually not an issue at all.)
> The only reasons to use shorts are: saving memory in arrays,interfacing
> to hardware.
> The portability argument is nonsense apart from the rare case where
> extra precision breaks code:
When you do need a short (like for referencing hardware) and you do want
your code to compile correctly with different compilers, portability
certainly does make sense, at least to me. How many times did you see
code posted to this newsgroup where a struct had ints as members, and
which works with Borland C, but breaks with DJGPP?
- Raw text -