From c00a460ea39f99578f063d348f2c2e14bf095caf Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Fri, 27 Apr 2018 14:30:13 -0700 Subject: [PATCH] [string] Drop StringStorage.create inlinability annotation. StringStorage.create is the primary means of allocating storage for a string, so drop inlinability to allow for future evolution. StringStorage also exposes some .appendInPlace methods, which we currently need to keep inlinable for benchmark performance. We'd really like to drop inlinability for these for evolution purposes (e.g. imagine a future version that adjusts nul-termination or changes in coordination with create). These are flagged with: ` // TODO(inlinability): @usableFromInline - P3` Where "P3" reflects urgency on a scale from 1 (stop the presses) to 5 (whatevs). --- stdlib/public/core/StringGuts.swift | 3 +-- stdlib/public/core/StringStorage.swift | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift index 5a277536ca7..6e156030c62 100644 --- a/stdlib/public/core/StringGuts.swift +++ b/stdlib/public/core/StringGuts.swift @@ -637,10 +637,9 @@ extension _StringGuts { return _copyToNativeStorage(of: CodeUnit.self, from: 0..( of codeUnit: CodeUnit.Type = CodeUnit.self, diff --git a/stdlib/public/core/StringStorage.swift b/stdlib/public/core/StringStorage.swift index f6a0217609c..36011e948c5 100644 --- a/stdlib/public/core/StringStorage.swift +++ b/stdlib/public/core/StringStorage.swift @@ -52,8 +52,10 @@ final class _SwiftStringStorage where CodeUnit : UnsignedInteger & FixedWidthInteger { /// Create uninitialized storage of at least the specified capacity. - @inlinable + @usableFromInline @nonobjc + @_specialize(where CodeUnit == UInt8) + @_specialize(where CodeUnit == UInt16) internal static func create( capacity: Int, count: Int = 0 @@ -191,7 +193,7 @@ extension _SwiftStringStorage { extension _SwiftStringStorage { // Append operations - @inlinable + @inlinable // TODO(inlinability): @usableFromInline - P3 @nonobjc internal final func _appendInPlace( _ other: _UnmanagedString @@ -203,7 +205,7 @@ extension _SwiftStringStorage { self.count += otherCount } - @inlinable + @inlinable // TODO(inlinability): @usableFromInline - P3 @nonobjc internal final func _appendInPlace(_ other: _UnmanagedOpaqueString) { let otherCount = Int(other.count) @@ -212,7 +214,7 @@ extension _SwiftStringStorage { self.count += otherCount } - @inlinable + @inlinable // TODO(inlinability): @usableFromInline - P3 @nonobjc internal final func _appendInPlace(contentsOf other: C) where C.Element == CodeUnit { @@ -225,7 +227,7 @@ extension _SwiftStringStorage { count += otherCount } - @inlinable + @inlinable // TODO(inlinability): @usableFromInline - P3 @_specialize(where C == Character._SmallUTF16, CodeUnit == UInt8) @nonobjc internal final func _appendInPlaceUTF16(contentsOf other: C)