Conversation
oschwald
commented
Sep 1, 2025
Owner
- perf: iterative nextValueOffset in DataDecoder
- perf: dual-child read + traversal tweaks
There was a problem hiding this comment.
Pull Request Overview
This PR implements minor performance improvements focused on reducing redundant operations in network traversal and data decoding. The changes optimize node reading by introducing a dual-child read function and replace recursive value offset calculation with an iterative approach.
- Introduces
readNodePairBySizefunction to read both left and right child pointers in a single operation - Replaces recursive
nextValueOffsetimplementation with iterative approach to reduce function call overhead - Updates network traversal code to use the new dual-child reading function
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| traverse.go | Updates NetworksWithin to use new readNodePairBySize function for reading both child pointers simultaneously |
| reader.go | Adds readNodePairBySize function that reads left and right child pointers in one operation with optimized bounds checking |
| internal/decoder/data_decoder.go | Converts recursive nextValueOffset to iterative implementation to reduce call stack overhead |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Comment on lines
+436
to
+437
| // To skip it, just move past the pointer bytes; do NOT follow | ||
| // the pointer target here. |
There was a problem hiding this comment.
[nitpick] The comment is helpful but could be more precise. Consider clarifying that we're skipping the pointer representation itself, not dereferencing the pointer to skip its target value.
Suggested change
| // To skip it, just move past the pointer bytes; do NOT follow | |
| // the pointer target here. | |
| // To skip it, just move past the pointer bytes representing the pointer itself; | |
| // do NOT dereference the pointer or skip the value it points to here. |
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.