Skip to content

Avoid some string allocations - #23402

Merged
AndyButland merged 7 commits into
umbraco:v17/devfrom
Henr1k80:v17/dev
Jul 17, 2026
Merged

AndyButland merged 7 commits into
umbraco:v17/devfrom
Henr1k80:v17/dev

Conversation

@Henr1k80

Copy link
Copy Markdown
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Avoid allocating strings when spans can be used when:

  • Parsing
  • Concatenating values
  • Splitting (here is also heap allocated an array to contain the strings)

This is archived by using spans from regex matches, trimming on spans & spans instead of sub-strings.

There is also

  • count single chars with spans instead of 2 string replace operations, that allocates strings.
  • removed some unneeded trim operations, that allocates a string, if trimming happens.

@AndyButland v17 version of #23399

@github-actions

Copy link
Copy Markdown

Hi there @Henr1k80, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@AndyButland AndyButland 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.

Thanks again @Henr1k80. Looks good, though I believe a regression has sneaked in here, so could you look at that before we merge please?

Comment thread src/Umbraco.Cms.Api.Delivery/Services/ApiMediaQueryService.cs Outdated

@AndyButland AndyButland 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.

Thanks for the updates @Henr1k80 - looks good to me now.

@AndyButland
AndyButland enabled auto-merge (squash) July 17, 2026 05:10
@AndyButland
AndyButland merged commit 5ff09f8 into umbraco:v17/dev Jul 17, 2026
29 checks passed
@Henr1k80
Henr1k80 deleted the v17/dev branch July 17, 2026 08:39
This was referenced Sep 17, 2026
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