Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replaced string concatenation by StringBuilder usage#95760

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rzikm merged 4 commits intodotnet:mainfromYohDeadfall:builder-instead-of-concat
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionssrc/libraries/System.Net.Mail/src/System.Net.Mail.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,8 @@
<Compile Include="System\Net\Mail\SmtpFailedRecipientsException.cs" />
<Compile Include="System\Net\Mail\SmtpStatusCode.cs" />
<Compile Include="System\Net\DelegatedStream.cs" />
<Compile Include="$(CommonPath)System\Text\ValueStringBuilder.cs"
Link="Common\System\Text\ValueStringBuilder.cs" />
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
Link="Common\DisableRuntimeMarshalling.cs" />
<Compile Include="$(CommonPath)System\Net\LazyAsyncResult.cs"
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,25 +51,26 @@ internal void ParseValue(string addresses)

internal string Encode(int charsConsumed, bool allowUnicode)
{
string encodedAddresses =string.Empty;
var encodedAddresses =new ValueStringBuilder(stackalloc char[256]);

//encode each address individually (except the first), fold and separate with a comma
foreach (MailAddress address in this)
{
if (string.IsNullOrEmpty(encodedAddresses))
if (encodedAddresses.Length == 0)
{
//no need to append a comma to the first one because it may be the only one.
encodedAddresses =address.Encode(charsConsumed, allowUnicode);
encodedAddresses.Append(address.Encode(charsConsumed, allowUnicode));
}
else
{
//appending another one, append a comma to separate and then fold and add the encoded address
//the charsConsumed will be 1 because only the first line needs to account for the header itself for
//line length; subsequent lines have a single whitespace character because they are folded here
encodedAddresses += ", " + address.Encode(1, allowUnicode);
encodedAddresses.Append(", ");
encodedAddresses.Append(address.Encode(1, allowUnicode));
}
}
return encodedAddresses;
return encodedAddresses.ToString();
}
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,6 +142,8 @@
Link="Common\System\HexConverter.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Compile Include="$(CommonPath)System\Text\ValueStringBuilder.cs"
Link="Common\System\Text\ValueStringBuilder.cs" />
</ItemGroup>
<!-- Unix specific files -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix'">
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp