Skip to content

Use span-based string.Concat instead of string.Substring - #13500

Merged
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
xtqqczze:span-string-concat
Oct 28, 2020
Merged

Use span-based string.Concat instead of string.Substring#13500
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
xtqqczze:span-string-concat

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Aug 21, 2020

Copy link
Copy Markdown
Contributor

PR Summary

Avoid some string allocations by using string.Concat(ReadOnlySpan, …) overloads.

Before:

str1 + str2.Substring(...) + str3

After:

string.Concat(str1, str2.AsSpan(...), str3)

PR Context

PR Checklist

Before:

```csharp
str1 + str2.Substring(...) + str3
```

After:
```csharp
string.Concat(str1, str2.AsSpan(...), str3)
```
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@xtqqczze

xtqqczze commented Sep 5, 2020

Copy link
Copy Markdown
Contributor Author

@xtqqczze xtqqczze changed the title Use span-based string.Concat inatead of string.Substring Use span-based string.Concat instead of string.Substring Oct 28, 2020
@xtqqczze

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) Could you please review?

@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Oct 28, 2020
@iSazonov Ilya (iSazonov) self-assigned this Oct 28, 2020
@ghost ghost removed the Review - Needed The PR is being reviewed label Oct 28, 2020
@iSazonov
Ilya (iSazonov) merged commit 69ded77 into PowerShell:master Oct 28, 2020
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.1 milestone Oct 28, 2020
@xtqqczze
xtqqczze deleted the span-string-concat branch October 28, 2020 10:16
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…13500)

Before:

```csharp
str1 + str2.Substring(...) + str3
```

After:
```csharp
string.Concat(str1, str2.AsSpan(...), str3)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants