Skip to content

Improve binary codec performance by caching SerializedType.bytes in subclasses. #557

@sappenin

Description

@sappenin

Currently, subclasses of SerializedType do not have access to the private final SerializedType#bytes field. Thus, in order to access those bytes (e.g., see AmountType#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 from SerializedType and then access values from there in a non-copy fashion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions