Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
... and 1 file with indirect coverage changes 📢 Thoughts on this report? Let us know! |
tgregg
reviewed
Aug 16, 2023
| final Block block = blocks.get(index); | ||
| block.data[offset] = (byte) value; | ||
| long bitValue = block.data[offset]; | ||
| if (value <= 0xD) { |
Contributor
There was a problem hiding this comment.
I suggest creating a new method (something like 'writeLowerNibbleAt'), and call it for this purpose, instead of branching within this method.
…ble of container type descriptor.
…d under 'writeUInt8At'.
336a846 to
0769dc0
Compare
Closed
This was referenced Apr 23, 2024
linlin-s
added a commit
that referenced
this pull request
May 9, 2024
…ble of container type descriptor. (#548)
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.
Issue #, if available:
N/A
Description of changes:
This PR optimize the process of overwriting lower nibble of type descriptor by avoid unnecessary method calls:
Context:
While writing containers, if the container length is small enough to fit in the lower nibble of the type descriptor byte, we will overwrite the lower nibble of the type descriptor byte with encoded length.
Before change, we need to use method
buffer.getUInt8At ()to calculate the OCTET of the type descriptor then combine it with the length value and then write the value to buffer by usingbuffer.writeVarUInt8At(). Both of these methods including calculationsindex = index(position),offset = offset(position). In this PR, we will pass the length value directly tobuffer.writeVarUInt8At()to avoid repeated calculations ofindexandoffset.Here are the benchmark results before and after changes:
Results from benchmarking a write of data equivalent to a stream of 194617 nested binary Ion value(3 forks, 2 warmups, 2 iterations, preallocation 1).
Results from benchmarking a write of data equivalent to a stream of 59155 nested binary Ion values(3 forks, 2 warmups, 2 iterations, preallocation 1).
Results from benchmarking a write of data equivalent to a single nested binary Ion value(3 forks, 2 warmups, 2 iterations, preallocation 1).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.