Skip to content

Replace std::vector with uint64_t bitset in WebRequestMethodComposite#410

Closed
Copilot wants to merge 6 commits intofix/402from
copilot/sub-pr-407
Closed

Replace std::vector with uint64_t bitset in WebRequestMethodComposite#410
Copilot wants to merge 6 commits intofix/402from
copilot/sub-pr-407

Conversation

Copy link

Copilot AI commented Mar 14, 2026

WebRequestMethodComposite used std::vector<WebRequestMethod> internally, causing heap allocations and fragmentation on embedded targets. The question was raised whether a uint64_t bitset would limit the method set to only 8 values.

Changes

  • Allocation-free storage: Replace std::vector<WebRequestMethod> with uint64_t _bits (one bit per http_method index) + bool _any for the HTTP_ANY (= 255) sentinel. The entire object is now 9 bytes with no heap involvement.
  • Capacity: A 64-bit bitmask supports indices 0–63. The http_method enum currently defines 34 values (0–33), so all methods fit with room to spare — not 8.
  • HTTP_ANY handling: Stored separately as bool _any; allows(HTTP_ANY) explicitly returns false (it is not a real request method, only a match-all sentinel).
// Before: heap-allocating list
std::vector<WebRequestMethod> _methods;

// After: 9-byte allocation-free bitset
uint64_t _bits;   // bit i set → method (http_method)i is allowed
bool _any;        // true → match any method (HTTP_ANY sentinel)

All public semantics (allows, operator==, operator|, operator&, empty, toString) are preserved.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 5 commits March 14, 2026 13:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mathieucarbou <61346+mathieucarbou@users.noreply.github.com>
Copilot AI changed the title [WIP] [WIP] Address feedback on HTTP method enum limitation Replace std::vector with uint64_t bitset in WebRequestMethodComposite Mar 14, 2026
Copilot AI requested a review from mathieucarbou March 14, 2026 13:16
@mathieucarbou mathieucarbou deleted the copilot/sub-pr-407 branch March 14, 2026 13:17
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