If been wondering about it some time now:
If you know the range of a variable,
is it more appropiate to set it to the respective Integer?
Lets say we have:
0 - 100 - Byte
0 - 30000 UInt16
etc.
Or should I just stick to the default Integer 2^32?
I've tested a bit and working with smaller Integers is a bit faster,
but only if you don't have to convert between them.
Which happens often since most classes like List(Of T), ArrayList, etc. work with Int32.
I know that regardless of what type I take the speed difference is neglectable,
at least in the program I'm currently writing,
but maybe there is a rule of thumb for something like that.
If you know the range of a variable,
is it more appropiate to set it to the respective Integer?
Lets say we have:
0 - 100 - Byte
0 - 30000 UInt16
etc.
Or should I just stick to the default Integer 2^32?
I've tested a bit and working with smaller Integers is a bit faster,
but only if you don't have to convert between them.
Which happens often since most classes like List(Of T), ArrayList, etc. work with Int32.
I know that regardless of what type I take the speed difference is neglectable,
at least in the program I'm currently writing,
but maybe there is a rule of thumb for something like that.