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

Consolidate String to UnsignedLong conversions in UIntType classes #500

Open
sappenin opened this issue Nov 29, 2023 · 0 comments
Open

Consolidate String to UnsignedLong conversions in UIntType classes #500

sappenin opened this issue Nov 29, 2023 · 0 comments

Comments

@sappenin
Copy link
Collaborator

sappenin commented Nov 29, 2023

Currently, UIntType has a Constructor that takes an UnsignedLong, which works mostly well.

However, in this hierarchy of calls, the UnsignedLong is converted into a hex-string so that it can be converted into a UnsignedByteArray.

In other places in the code (e.g., JSON deserialization), we start with a hex string, convert to an UnsignedLong, then pass this value up the constructor chain only to be converted back into a String and then to a ByteArray.

We should be able to make this more efficient, such as by creating a set of protected constructors in UIntType that allows a hex-string to be suppllied, and then coverted to an UnsignedByteArray, potentially skipping the conversion into an UnsignedLong.

However, to be safe, we should test a variety of inputs here to make sure that the intermediate conversion to UnsignedLong isn't actually doing something useful that's required before conversion to an UnsignedByteArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant