Date: Wed, 24 Sep 1997 16:57:46 +0200 (IST) From: Eli Zaretskii To: djgpp AT delorie DOT com Subject: Re: %d In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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?