Skip to content

[Windows] Optimize formatted labels #28073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Feb 27, 2025

Description of Change

Optimizes formatted texts on Windows. Sample:

<Label>
  <Label.FormattedText>
    <FormattedString>
      <Span Text=" A " />
      <Span Text=" B " />
      <Span Text=" C " />
    </FormattedString>
  </Label.FormattedText>
</Label>

Performance impact

image

Speedscopes:

-> Improvement of ~56%

@MartyIX MartyIX requested a review from a team as a code owner February 27, 2025 10:36
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 27, 2025
@@ -41,7 +41,8 @@ public static void UpdateInlines(
Color? defaultColor = null,
TextTransform defaultTextTransform = TextTransform.Default)
{
textBlock.Inlines.Clear();
var textBlockInlines = textBlock.Inlines;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Store Inlines in a variable to avoid perf hit.

@jsuarezruiz jsuarezruiz added platform/windows 🪟 area-controls-label Label, Span t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) labels Feb 27, 2025
@jfversluis
Copy link
Member

/azp run

@jfversluis jfversluis added this to the .NET 9 SR5 milestone Feb 28, 2025
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen moved this from Todo to Approved in MAUI SDK Ongoing Mar 3, 2025
@PureWeen
Copy link
Member

PureWeen commented Mar 3, 2025

  • test failures on unrelated platforms

@PureWeen PureWeen merged commit 804abf3 into dotnet:main Mar 3, 2025
110 of 124 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Mar 3, 2025
@MartyIX MartyIX deleted the feature/2025-02-27-optimize-formatted-label-on-Windows-2 branch March 3, 2025 18:09
tj-devel709 pushed a commit that referenced this pull request Mar 3, 2025
bhavanesh2001 pushed a commit to bhavanesh2001/maui that referenced this pull request Mar 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-label Label, Span community ✨ Community Contribution platform/windows 🪟 t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants