Skip to content

Conversation

oschwald
Copy link
Owner

@oschwald oschwald commented Sep 1, 2025

  • perf: iterative nextValueOffset in DataDecoder
  • perf: dual-child read + traversal tweaks

@oschwald oschwald requested a review from Copilot September 1, 2025 19:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 readNodePairBySize function to read both left and right child pointers in a single operation
  • Replaces recursive nextValueOffset implementation 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.
Copy link
Preview

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

1 participant