Skip to content

Conversation

@soniseth0
Copy link
Contributor

precompute the total concatenated length in ConcatByteSlices, allocate the output slice once with the exact capacity, keep existing behavior for empty or nil inputs while removing redundant allocations

Copy link
Member

@joshuacolvin0 joshuacolvin0 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

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 optimizes the ConcatByteSlices function to improve performance by eliminating repeated slice reallocations. Instead of starting with an empty slice and allowing append operations to trigger multiple reallocations as capacity is exceeded, the function now pre-calculates the total required capacity and allocates the output slice once with the exact size needed.

Key changes:

  • Pre-computes total length of all input slices before concatenation
  • Allocates output slice with exact capacity upfront using make([]byte, 0, totalLen)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@joshuacolvin0 joshuacolvin0 added this pull request to the merge queue Nov 26, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
@joshuacolvin0 joshuacolvin0 removed this pull request from the merge queue due to a manual request Nov 26, 2025
@joshuacolvin0 joshuacolvin0 added this pull request to the merge queue Nov 26, 2025
Merged via the queue into OffchainLabs:master with commit f5f5be8 Nov 26, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants