-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Optimize Strings.toString(uint)
implementation
#3190
Comments
Thank you @3sGgpQ8H. Can you elaborate on what exactly makes the current implementation inefficient and what is the reason we would see an improvement with the link you shared? |
Sure.
|
Got it. Agree with the first point. Perhaps we should have a general purpose For the second point we need to consider that As a side note, do you see this function being used on-chain as opposed to off-chain queries? |
Look at the StackOverflow answer referred in the original post.
Surely, its its primary purpose is to be used on-chain. For off-chain use it would be more efficient to return a number and convert to a string off-chain (i.e. in UI). Two quite common on-chain usages are:
|
I hadn't realized the StackOverflow answer was Solidity. 🙂 Signatures are a decent use case, though a standard like EIP712 doesn't convert them to decimal format. NFT URIs are not normally computed on chain as far as I know. In any case I think it makes sense to optimize this. |
🧐 Motivation
The current
Strings.toString(uint)
implementation is quite inefficient on large inputs.📝 Details
Consider optimizing it as suggested here: https://stackoverflow.com/a/71095692/2038768
The text was updated successfully, but these errors were encountered: