Skip to content

chore: Avoid one clone and use better iterators#6557

Merged
Hywan merged 2 commits into
matrix-org:mainfrom
Hywan:fix-clippy
May 10, 2026
Merged

chore: Avoid one clone and use better iterators#6557
Hywan merged 2 commits into
matrix-org:mainfrom
Hywan:fix-clippy

Conversation

@Hywan

@Hywan Hywan commented May 8, 2026

Copy link
Copy Markdown
Member

The first patch uses slice::from_ref to create a &[T] from a &T. In our case, it saves the cost of one clone.

The second patch uses values() instead of iter() and discard the keys.


  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was made with the help of AI.

Hywan added 2 commits May 8, 2026 14:56
This patch uses `slice::from_ref` to create a `&[T]` from a `&T`. In our
case, it saves the cost of one clone.
@Hywan Hywan requested a review from a team as a code owner May 8, 2026 13:00
@Hywan Hywan requested review from stefanceriu and removed request for a team May 8, 2026 13:00
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.92%. Comparing base (f4b2794) to head (ab60a3a).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/room/knock_requests.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6557      +/-   ##
==========================================
- Coverage   89.93%   89.92%   -0.02%     
==========================================
  Files         381      381              
  Lines      106865   106865              
  Branches   106865   106865              
==========================================
- Hits        96112    96095      -17     
- Misses       7101     7117      +16     
- Partials     3652     3653       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented May 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing Hywan:fix-clippy (ab60a3a) with main (6a33b94)

Open in CodSpeed

@stefanceriu stefanceriu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using a somewhat unknown module and method to avoid a string clone is pushing it but sure, why not 😁
Could've easily been part of any other PR I reckon.

@Hywan Hywan merged commit 65072dd into matrix-org:main May 10, 2026
54 checks passed
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.

2 participants