I have a byte[] which contains serialised C++ data types (so it has a weird format that the standard Java serialisation classes can't understand). I've created my own deserialiser which matches flags to types and converts it into the appropriate object, like so (input could be something like this int64 with value 4 [3, 0, 0, 0, 0, 0, 0, 0, 4], 3 is the flag for int64)
private final ByteBuffer byteWrapper;
// member ByteBuffer which is allocated in the ctor
ctor { byteWrapper = ByteBuffer.allocateDirect(8); }
// somewhere in the parse function, this case matches an int64
case 3:
{
return byteWrapper.wrap(ios.getBytes(8)).getLong();
}
Where ios contains the full serialisation data for easy reading. Now this works fine, but high throughput is very important for this piece of the code and I'm not a regular Java programmer, so I'm just wondering if anyone has any suggestions for speeding this process up, either by reworking what I've got or using different classes/functions entirely or anything? Memory is not an issue, I'm just interested in speed