Improve binary codec performance by caching SerializedType.bytes
in subclasses.
#557
Labels
enhancement
New feature or request
SerializedType.bytes
in subclasses.
#557
Currently, subclasses of
SerializedType
do not have access to the private finalSerializedType#bytes
field. Thus, in order to access those bytes (e.g., seeAmountType#isNative
) the byte array is copied in order to provide immutable access to sub-classes.From a performance perspective, this is mostly just fine because we don't expect xrpl4j to be processing such heavy transaction load that this byte-array copy will matter. However, this might matter.
Thus, because the
bytes
array is meant to be immutable (and the current pattern we see here exists because Java has not immutable/final array primitive), we can copy the bytes array once fromSerializedType
and then access values from there in a non-copy fashion.The text was updated successfully, but these errors were encountered: