Actually, I suspect that you might take a performance hit. There are only Java bytecodes for bitwise operations on int
and long
values. So the short
values in permission
and requested
variables need (in theory) to be sign-extended before the operation is performed.
(And besides, I think you will find that the native bit-wise instructions are only available in 32 and 64 bit. Or if there are 8 or 16 bit versions, they will take the same number of clocks as the 32 bit version. The CPU datapaths will be at least 32 bits wide, and for and/or/xor there is no way to make narrower types work faster.)
In addition, even though the three variables have type short
, the JVM will allocate the same number of bytes to store them. This is a consequence of the way that the JVM is designed.
So if your aim in using short
was to save space or time, it probably won't help. But the only way to be sure is to use a profiler to compare the short
and int
versions of your application ... or better still, just forget about it.