shorts vs. ints on a VAX 11/750

Wayne A. Christopher faustus at ucbcad.UUCP
Thu Jul 18 04:12:05 AEST 1985


> I noted today that variables in "ex_vis.h" were declared to be type "short"
> rather than type "int."  Now my own experience with our VAX 11/750 has been
> that it pays to declare (non-array) variables to be "int" rather than "short";
> this avoids all sorts of "cvtxx"s at run time, and seems to more than 
> compensate for the extra memory fetches involved in using "int"s rather
> than "short"s. And yet I've got to believe that there was a good reason 
> for using shorts in vi.

Well, there isn't any extra overhead with fetching a long as opposed to a
short -- the fetch is always 32 bits. 

> If you have insights in to using shorts versus using ints on the VAX 11/750
> in general, or shorts versus ints in vi in particular, I'd appreciate hearing
> from you.

I can think of a few: if you are using a lot of them, then maybe you are
concerned with space -- with just a few of them probably that isn't a
problem though. Also, in something like vi, which should be pretty portable
and was written on a 16-bit machine, it seems like good style to me to
be clear about whether you want a variable to have 16 or 32 bits -- an
int can be either, depending on what machine you are running on, and you
can get used to thinking of an int as 32 bits and get into trouble when
it isn't...

	Wayne



More information about the Comp.unix.wizards mailing list