Content-Length: 351045 | pFad | https://github.com/nghttp2/nghttp2/pull/2340

04 Refactor allocator by tatsuhiro-t · Pull Request #2340 · nghttp2/nghttp2 · GitHub
Skip to content

Refactor allocator#2340

Merged
tatsuhiro-t merged 4 commits intomasterfrom
refactor-allocator
May 1, 2025
Merged

Refactor allocator#2340
tatsuhiro-t merged 4 commits intomasterfrom
refactor-allocator

Conversation

@tatsuhiro-t
Copy link
Member

No description provided.

@tatsuhiro-t tatsuhiro-t added this to the v1.66.0 milestone May 1, 2025
@tatsuhiro-t tatsuhiro-t requested a review from Copilot May 1, 2025 08:57
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 the allocator functions to leverage C++20 ranges for copying and streamlines function signatures for string manipulation.

  • Replaces std::copy/_n with std::ranges::copy/_n for improved clarity and efficiency.
  • Revises function template parameters to use the declared BlockAllocator type rather than a templated one.
  • Adjusts function qualifiers (inline/constexpr) for consistency in header functions.

auto p = dst;
p = std::copy(std::begin(src), std::end(src), p);
*p = '\0';
*std::ranges::copy(src, dst).out = '\0';
Copy link

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider splitting the std::ranges::copy call and the subsequent assignment to '\0' into two separate statements for improved readability.

Suggested change
*std::ranges::copy(src, dst).out = '\0';
auto copy_result = std::ranges::copy(src, dst);
*copy_result.out = '\0';

Copilot uses AI. Check for mistakes.
// private function used in concat_string_ref. this is the base
// function of concat_string_ref_count().
inline constexpr size_t concat_string_ref_count(size_t acc) { return acc; }
constexpr size_t concat_string_ref_count(size_t acc) { return acc; }
Copy link

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] For consistency, consider marking similar header-defined functions with 'inline' alongside 'constexpr' to avoid potential ODR issues.

Suggested change
constexpr size_t concat_string_ref_count(size_t acc) { return acc; }
inline constexpr size_t concat_string_ref_count(size_t acc) { return acc; }

Copilot uses AI. Check for mistakes.
@tatsuhiro-t tatsuhiro-t merged commit e47a2cc into master May 1, 2025
87 checks passed
@tatsuhiro-t tatsuhiro-t deleted the refactor-allocator branch May 1, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/nghttp2/nghttp2/pull/2340

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy