Skip to content

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

Merged
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
iSazonov merged 1 commit into
PowerShell:masterfrom
xtqqczze:span-string-concat

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Aug 21, 2020

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 ghost assigned anmenaga Aug 21, 2020
@ghost ghost added the Review - Needed The PR is being reviewed label Sep 5, 2020
@ghost
Copy link
Copy Markdown

ghost commented Sep 5, 2020

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
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Sep 5, 2020

@adityapatwardhan, @daxian-dbw Can you please review?

@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

@iSazonov Could you please review?

@iSazonov 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 iSazonov self-assigned this Oct 28, 2020
@ghost ghost removed the Review - Needed The PR is being reviewed label Oct 28, 2020
@iSazonov iSazonov merged commit 69ded77 into PowerShell:master Oct 28, 2020
@iSazonov 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

ghost commented Nov 17, 2020

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

Handy links:

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