FFFF Review using StringBuilder in pinvokes · Issue #9139 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Review using StringBuilder in pinvokes #9139

@iSazonov

Description

@iSazonov

From https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/interop-pinvokes.md#strings

StringBuilder marshalling always re-allocate/re-copy buffers. Make sense review our code to reduce such allocations.

From @daxian-dbw #9066 (comment)

it seems StringBuilder should never be used for P/Invoke as it incurs 4 allocations. I think it make sense to review our uses of it and replace with ArrayPool when appropriate, because we will copy the existing pattern when writing new code.

From above docs:

[USE] Char arrays from ArrayPool or StringBuffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalityResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0