Closed
Conversation
shargon
commented
Dec 2, 2025
| Span<byte> span = data.AsSpan(offset, size); | ||
|
|
||
| if (BitConverter.IsLittleEndian) | ||
| span.Reverse(); |
Member
Author
There was a problem hiding this comment.
@erikzhang we loose performance here, because in regular nodes we always need to reverse each key, before the change this was faster
Member
There was a problem hiding this comment.
Have you tested it? Approximately how much performance was lost?
Member
Author
There was a problem hiding this comment.
I don't have a benchmark. it depends a lot on the key size, but previously an integer was written directly inverted, and now it requires an extra loop to reverse it. Also, I think a string gets reversed, and it shouldn't; only an integer should be reversed.
cschuchardt88
approved these changes
Dec 2, 2025
Member
|
If it is used for #4348, I think it's easy to extract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Required for #4348
This pull request introduces a new parsing capability to the
KeyBuilderclass in the smart contract library, allowing for extraction of key components from a byte array, and adds corresponding unit tests to verify this functionality. The most important changes are grouped below by theme.KeyBuilder enhancements
TryParsetoKeyBuilderthat parses a byte array into its constituent id, prefix, and value fields, supporting multiple value types. This improves the ability to decompose storage keys for inspection or validation.ReadStructfor safely reading value types from a byte span using marshaling.PrefixLengthfromKeyBuilder, simplifying the class.Unit testing
TestTryParsetoUT_KeyBuilder.csto verify correct parsing of various key formats and error conditions for the newTryParsemethod.System.Reflection, supporting new test logic.Type of change
How Has This Been Tested?
Checklist: