From c4f82672cb943413e4e9b3c68efda7d0dd97d02a 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/corefx#32072) * Fix ServiceController name population perf * Split tests * Remove dead field * Remove new use of DangerousGetHandle * SafeHandle all the things! * VSB #1 * VSB #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 --- .../shared/System/Text/ValueStringBuilder.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs index 21cc3dc01..74b5dacf9 100644 --- a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs @@ -48,11 +48,22 @@ namespace System.Text Grow(capacity - _chars.Length); } + /// + /// 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) {