Skip to content

perf: replace source to original#203

Merged
SyMind merged 5 commits intomainfrom
perf-replace-source-to-original-source
Nov 7, 2025
Merged

perf: replace source to original#203
SyMind merged 5 commits intomainfrom
perf-replace-source-to-original-source

Conversation

@SyMind
Copy link
Copy Markdown
Collaborator

@SyMind SyMind commented Nov 7, 2025

This PR introduces a performance optimization for ReplaceSource when wrapping OriginalSource by adding a method to identify original sources and skip expensive content validation.

  • Added is_original_source() method to the Chunks trait with a default implementation returning false
  • Implemented the method to return true for OriginalSourceChunks
  • Optimized ReplaceSource to skip content validation when processing an OriginalSource

Copilot AI review requested due to automatic review settings November 7, 2025 03:37
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 7, 2025

CodSpeed Performance Report

Merging #203 will improve performances by ×2.4

Comparing perf-replace-source-to-original-source (2e10f13) with main (ee72991)

Summary

⚡ 1 improvement
✅ 10 untouched
⏩ 6 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
complex_replace_source_map 49.2 ms 20.4 ms ×2.4

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.

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 introduces a performance optimization for ReplaceSource when wrapping OriginalSource by adding a method to identify original sources and skip expensive content validation.

  • Added is_original_source() method to the Chunks trait with a default implementation returning false
  • Implemented the method to return true for OriginalSourceChunks
  • Optimized ReplaceSource to skip content validation when processing an OriginalSource

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/helpers.rs Added is_original_source() trait method with documentation explaining its use as a performance optimization hint
src/original_source.rs Implemented is_original_source() to return true for OriginalSourceChunks
src/replace_source.rs Added optimization to skip expensive content validation when processing an OriginalSource by checking is_original_source()

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

@SyMind SyMind force-pushed the perf-replace-source-to-original-source branch from 9277b40 to a660667 Compare November 7, 2025 03:54
@SyMind SyMind force-pushed the perf-replace-source-to-original-source branch from f53cd70 to 2e10f13 Compare November 7, 2025 06:20
@SyMind SyMind merged commit aea29de into main Nov 7, 2025
10 checks passed
@SyMind SyMind deleted the perf-replace-source-to-original-source branch November 7, 2025 07:11
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