I have this piece of code:
palette = new Array(paletteSize);
for (var i:int=0;i<paletteSize;i++) {
palette[i] = 0xFF000000
| (inputStream.readUnsignedByte() << 16)
| (inputStream.readUnsignedByte() << 8)
| (inputStream.readUnsignedByte());
}
This code is executed around 300 times and each time paletteSize varies from 1-255. So, on the whole this code takes around 60-80ms. Can this be optimized in some way? inputStream(IDataInput) is a socket connection and it does not spend any time waiting on i/o. This code is only executed when enough number of bytes are available in stream.