Skip to content

[utils] perf: reuse the quoted-string regular expression - #13150

Open
pengbanban wants to merge 1 commit into
mudler:masterfrom
pengbanban:my_feature
Open

pengbanban wants to merge 1 commit into
mudler:masterfrom
pengbanban:my_feature

Conversation

@pengbanban

@pengbanban pengbanban commented Nov 8, 2026 •

Copy link
Copy Markdown

Description

EscapeNewLines recompiles the same quoted-string regular expression for every call made by function-output parsing and grammar generation. Compile it once at package initialization, as is already done for the newline matcher.

Notes for Reviewers

Ginkgo/Gomega cases preserve escaped quotes, newlines inside strings, and formatting whitespace outside strings. A focused benchmark measured 54 allocations per call before the change and 16 afterwards in the initial same-input harness; the final package benchmark also reports 16. These are microbenchmark allocation results, not an application-throughput claim.

The focused package suite passed 4 specs. The complete app build, model suites and make lint were not run.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

Signed-off-by: pengbanban <pengqichugui@outlook.com>

This branch has not been deployed

No deployments
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