Skip to content

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Oct 28, 2025

This PR refactors ReplaceSource and CachedSource to use trait objects (BoxSource) instead of generic type parameters, improving ergonomics and enabling runtime type checking. The key optimization checks if a BoxSource already wraps a CachedSource to avoid double-caching.

Key Changes:

  • Converted ReplaceSource<T> and CachedSource<T> from generic structs to concrete structs using BoxSource
  • Added optimization in CachedSource::new() to detect and unwrap existing CachedSource instances
  • Removed original() methods from both structs since the inner source is now a trait object
Copilot AI review requested due to automatic review settings October 28, 2025 02:10
Copy link

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 refactors ReplaceSource and CachedSource to use trait objects (BoxSource) instead of generic type parameters, improving ergonomics and enabling runtime type checking. The key optimization checks if a BoxSource already wraps a CachedSource to avoid double-caching.

Key Changes:

  • Converted ReplaceSource<T> and CachedSource<T> from generic structs to concrete structs using BoxSource
  • Added optimization in CachedSource::new() to detect and unwrap existing CachedSource instances
  • Removed original() methods from both structs since the inner source is now a trait object

Reviewed Changes

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

File Description
src/replace_source.rs Converts ReplaceSource<T> to use BoxSource, removes Arc wrapper and original() method, simplifies trait implementations
src/cached_source.rs Converts CachedSource<T> to use BoxSource, adds double-caching prevention logic, removes original() method

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

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 28, 2025

CodSpeed Performance Report

Merging #183 will not alter performance

Comparing SyMind:perf-rm-inner-cached-source (94d18ea) with main (faf2138)

Summary

✅ 9 untouched
⏩ 4 skipped1

Footnotes

  1. 4 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.

@JSerFeng JSerFeng merged commit 8447380 into web-infra-dev:main Oct 28, 2025
7 checks passed
@SyMind SyMind deleted the perf-rm-inner-cached-source branch October 28, 2025 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants