<regex>: Remove dynamic array resizing from _Buf - #6453
Open
Julian Müller (muellerj3) wants to merge 1 commit into
Open
Julian Müller (muellerj3) wants to merge 1 commit into
Julian Müller (muellerj3) wants to merge 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Julian Müller (muellerj3)
September 16, 2026 22:35
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
All assignments use known non-empty inputs, preserve bounds checks, and maintain the existing ABI layout.
Pull request overview
Simplifies regex character buffers by allocating their final size in one operation.
Changes:
- Replaces incremental
_Insert2growth with_Assignoverloads. - Preserves
_Szfor ABI compatibility. - Updates all buffer-population call sites.
File summaries
| File | Description |
|---|---|
stl/inc/regex |
Implements exact-size buffer allocation and updates callers. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After the most recent change, all
_Bufobjects are populated by a single_Insert2call. This means that we can immediately allocate the correct amount of memory instead of dynamically growing the internal array.This PR replaces the code for dynamically resizing
_Buf's internal array by two new functions_Assign()that perform a single allocation of the correct size and initialize the allocated memory. As a result, the capacity member_Szhas lost its raison d'être (but we must retain it to preserve ABI).As a char-like type [re.general/2],
_Elemis required to be trivially copyable [string.general/2] (and<regex>doesn't support constexpr evaluation yet), so we do not have to explicitly construct and destruct the elements.