Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sappenin opened this issue Oct 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sappenin
Copy link
Collaborator

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.

@sappenin sappenin added the enhancement New feature or request label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
@sappenin and others