Skip to content

Use std::ranges::copy with std::span directly#810

Merged
laurynas-biveinis merged 1 commit into
masterfrom
c++20-ranges
Nov 27, 2025
Merged

Use std::ranges::copy with std::span directly#810
laurynas-biveinis merged 1 commit into
masterfrom
c++20-ranges

Conversation

@laurynas-biveinis
Copy link
Copy Markdown
Collaborator

@laurynas-biveinis laurynas-biveinis commented Nov 25, 2025

Replace std::copy with pointer arithmetic on std::span with
std::ranges::copy that takes the span range directly, simplifying
the code.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Tests
    • Updated test utilities and test cases to use modern C++ ranges-based copying and style improvements, maintaining existing behavior and public interfaces.

✏️ Tip: You can customize this high-level summary in your review settings.

@laurynas-biveinis laurynas-biveinis self-assigned this Nov 25, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 25, 2025

Walkthrough

Two test files were changed to use C++20's std::ranges::copy in place of std::copy; no signature or behavior changes were made and control flow remains identical.

Changes

Cohort / File(s) Summary
Use std::ranges::copy in tests
test/db_test_utils.hpp, test/test_key_encode_decode.cpp
Replaced std::copy with std::ranges::copy when copying encoded key bytes into containers. No behavioral changes or API signature edits. No new public symbols.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Small, consistent refactor across two test files.
  • Check that <ranges> is available/included in the translation unit or transitively included; ensure no surprising ADL or overload resolution changes.
  • Verify build on target compilers if C++20 ranges support varies.

Poem

Old copies yield to a sleeker sweep,
Ranges step in, their promise keep.
Tests unchanged in deed and name,
A modern swap — the code's the same. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing std::copy with std::ranges::copy to work directly with std::span, which aligns with both file summaries.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch c++20-ranges

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1899148 and 5dfe1dc.

📒 Files selected for processing (2)
  • test/db_test_utils.hpp (1 hunks)
  • test/test_key_encode_decode.cpp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
test/db_test_utils.hpp (1)

257-258: LGTM - Clean C++20 simplification.

The replacement of std::copy with std::ranges::copy is correct. The destination array size matches the source span size (both 8 bytes for std::uint64_t), so the copy is safe. The new syntax is more concise.

test/test_key_encode_decode.cpp (1)

680-682: LGTM - Straightforward ranges adoption.

The change from std::copy to std::ranges::copy is correct. The destination vector is sized to match the source span (line 679), making the copy safe. The return statement correctly constructs a key_view from the copied data.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.45%. Comparing base (6caea31) to head (5dfe1dc).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #810      +/-   ##
==========================================
+ Coverage   98.33%   98.45%   +0.12%     
==========================================
  Files          35       35              
  Lines        6493     6493              
==========================================
+ Hits         6385     6393       +8     
+ Misses        108      100       -8     
Flag Coverage Δ
Debug 98.21% <100.00%> (-0.13%) ⬇️
Release 97.57% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace std::copy with pointer arithmetic on std::span with
std::ranges::copy that takes the span range directly, simplifying
the code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@laurynas-biveinis laurynas-biveinis merged commit fd24ccc into master Nov 27, 2025
229 of 231 checks passed
@laurynas-biveinis laurynas-biveinis deleted the c++20-ranges branch November 27, 2025 03:59
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.

1 participant