Skip to content

<regex>: Remove dynamic array resizing from _Buf - #6453

Open
Julian Müller (muellerj3) wants to merge 1 commit into
microsoft:mainfrom
muellerj2:regex-make-_Buf-fixed-size
Open

Julian Müller (muellerj3) wants to merge 1 commit into
microsoft:mainfrom
muellerj2:regex-make-_Buf-fixed-size

Conversation

@muellerj3

Copy link
Copy Markdown
Contributor

After the most recent change, all _Buf objects are populated by a single _Insert2 call. 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 _Sz has lost its raison d'être (but we must retain it to preserve ABI).

As a char-like type [re.general/2], _Elem is 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.

@muellerj3
Julian Müller (muellerj3) requested a review from a team as a code owner September 16, 2026 22:35
Copilot AI balanced review requested due to automatic review settings September 16, 2026 22:35
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Sep 16, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 _Insert2 growth with _Assign overloads.
  • Preserves _Sz for 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.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added performance Must go faster regex meow is a substring of homeowner labels Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster regex meow is a substring of homeowner

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

3 participants