Skip to content

Avoid building StringBuilder in DefaultInterpolatedStringHandler #105775

Closed

Description

@alrz

When passing a builder to an interpolation $".. {stringBuilder} .." the builder is first converted to an string, duplicating the total allocation needed to evaluate this expression. Could DefaultInterpolatedStringHandler specially handle builders so that this doesn't happen?

Activity

  1. added
    tenet-performance
    on Jul 31, 2024
  2. ghost added
    needs-area-label
    on Jul 31, 2024
  3. added
    untriaged
    on Jul 31, 2024
  4. changed the title [-]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler.AppenFormatted<T>(T)`[/-] [+]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler`[/+] on Jul 31, 2024
  5. stephentoub commented on Jul 31, 2024

    @stephentoub
    Member

    I'm not excited at the idea of special-casing StringBuilder in DefaultInterpolatedStringHandler. If it's a problem to be solved, I'd rather it be solved by having StringBuilder implement ISpanFormattable.

  6. dotnet-policy-service commented on Aug 1, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-runtime
    See info in area-owners.md if you want to be subscribed.

  7. karakasa commented on Aug 2, 2024

    @karakasa
    Contributor

    So is implementing ISpanFormattable on StringBuilder an api-suggestion?

  8. stephentoub commented on Aug 2, 2024

    @stephentoub
    Member

    So is implementing ISpanFormattable on StringBuilder an api-suggestion?

    yup

  9. karakasa commented on Aug 2, 2024

    @karakasa
    Contributor

    OK. Let me propose an issue.

  10. removed
    needs-area-label
    on Aug 2, 2024
  11. jeffhandley commented on Aug 6, 2024

    @jeffhandley
    Member

    Closed with the creation of #105870

  12. removed
    untriaged
    on Aug 6, 2024
  13. locked and limited conversation to collaborators on Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtimetenet-performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions