Skip to content

perf: ConcatSource source#199

Merged
SyMind merged 1 commit intomainfrom
perf-concat-source-fn
Nov 5, 2025
Merged

perf: ConcatSource source#199
SyMind merged 1 commit intomainfrom
perf-concat-source-fn

Conversation

@SyMind
Copy link
Copy Markdown
Collaborator

@SyMind SyMind commented Nov 5, 2025

Since the performance of the RspackSource size method has been optimized previously, it is a very good optimization to pre-allocate the capacity for String using the size method here.

Copilot AI review requested due to automatic review settings November 5, 2025 04:08
Copy link
Copy Markdown

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 ConcatSource implementation by replacing rope-based string concatenation with direct string building using pre-allocated capacity. The changes improve performance by reducing intermediate allocations and avoiding the overhead of rope operations when building the final source string.

Key changes:

  • Refactored source() method to build strings directly with pre-allocated capacity instead of using rope
  • Added capacity pre-allocation to buffer() method using self.size()

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #199 will improve performances by 81.88%

Comparing perf-concat-source-fn (8e6da83) with main (4310b76)

Summary

⚡ 1 improvement
✅ 9 untouched
⏩ 6 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
repetitive_react_components_source 478.9 µs 263.3 µs +81.88%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@SyMind SyMind merged commit 0d3ca2b into main Nov 5, 2025
16 checks passed
@SyMind SyMind deleted the perf-concat-source-fn branch November 5, 2025 04:13
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.

3 participants