From c4b7537ffdb33e2e7e61d367d04478076dfd7c42 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Tue, 4 Sep 2018 15:21:28 -0700 Subject: [PATCH] Fix ServiceController name population perf (dotnet/corefxdotnet/coreclr#32072) * Fix ServiceController name population perf * Split tests * Remove dead field * Remove new use of DangerousGetHandle * SafeHandle all the things! * VSB dotnet/coreclr#1 * VSB dotnet/coreclr#2 * Fix GLE * Initialize machineName in ctor * Test for empty name ex * Null names * Inadvertent edit * Unix build * Move interop into class * Reverse SafeHandle for HAllocGlobal * Fix tests * Disable test for NETFX * CR feedback * Pattern matching on VSB * Direct call * typo Signed-off-by: dotnet-bot Commit migrated from https://github.com/dotnet/coreclr/commit/20ee9b884cdc04826826b95e0952f9c5b5e650dc --- .../src/System/Text/ValueStringBuilder.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs index 21cc3dc..74b5dac 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs @@ -50,9 +50,20 @@ namespace System.Text /// /// Get a pinnable reference to the builder. + /// Does not ensure there is a null char after + /// This overload is pattern matched in the C# 7.3+ compiler so you can omit + /// the explicit method call, and write eg "fixed (char* c = builder)" + /// + public ref char GetPinnableReference() + { + return ref MemoryMarshal.GetReference(_chars); + } + + /// + /// Get a pinnable reference to the builder. /// /// Ensures that the builder has a null char after - public ref char GetPinnableReference(bool terminate = false) + public ref char GetPinnableReference(bool terminate) { if (terminate) { -- 2.7.4