Skip to content

[6.x] Improve CP TrimStrings performance with large Bard content - #16012

Merged
jasonvarga merged 1 commit into
6.xfrom
trim-strings-performance
Nov 23, 2026
Merged

jasonvarga merged 1 commit into
6.xfrom
trim-strings-performance

Conversation

@jasonvarga

Copy link
Copy Markdown
Member

The CP TrimStrings middleware tracked each Bard text node by appending its key to the $except list, then searched that list for every value in the request. Requests with a lot of text nodes got disproportionately slower as the list grew.

Text nodes are now handled inline by restoring the original text after trimming, so no list is built up. This also prevents the exclusions from carrying over if the middleware instance is reused.

Text nodes are now handled inline by restoring the original text after trimming, instead of appending each node's key to $except and searching that list for every value. This keeps the cost linear in the number of text nodes and stops exclusions carrying over if the middleware instance is reused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit b0ea51b into 6.x Nov 23, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the trim-strings-performance branch November 23, 2026 15:48
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