Ross,

I tend to use Integer for everything and Int64 only when I know Integer does
not have enough bits.  I almost never bother with the lower precision
integers.  There is hardly any speed difference.  Fetching an aligned 16-bit
integer from memory is just as fast as fetching an aligned 32-bit integer.
Furthermore, you are not going to save any memory using 16-bit integers, as
Delphi automatically generates code that aligns variables to 32-bit
boundary.  The only case when you would save memory is if you have a packed
array.

If you need to explicitly limit the value, it is better to use a sub-range
type and turn range checking on.

Dennis.

----- Original Message ----- 
From: "Ross Levis" <[EMAIL PROTECTED]>

I've tended to use ShortInt and SmallInt rather than Integer to not waste
memory when values are never going to exceed their maximum, but I read
somewhere that Integer should be used when possible for speed purposes.

I've found it slightly useful when reading the source to know that a
particular variable doesn't ever exceed 127 or 32767.

What sort of speed differences are we talking about?  Is it worth doing a
global find/replace?

Cheers,
Ross Levis.
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to