Skip to content

Commit f98e251

Browse files
glessardlorentey
andcommitted
Apply suggestions from code review
Co-authored-by: Karoy Lorentey <[email protected]>
1 parent 0eb6ad3 commit f98e251

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

stdlib/public/core/StringGuts.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ extension _StringGuts {
423423
private static var associationKey: UnsafeRawPointer {
424424
// We never dereference this, we only use this address as a unique key
425425
unsafe unsafeBitCast(
426-
ObjectIdentifier(_StringGuts.self),
426+
ObjectIdentifier(__StringStorage.self),
427427
to: UnsafeRawPointer.self
428428
)
429429
}
@@ -437,7 +437,6 @@ extension _StringGuts {
437437
) -> UnsafeRawPointer?).self
438438
)
439439
_precondition(_object.hasObjCBridgeableObject)
440-
// print("has ObjC Bridgeable Object")
441440
if let assocPtr = unsafe getter(
442441
_object.objCBridgeableObject,
443442
Self.associationKey
@@ -484,7 +483,7 @@ extension _StringGuts {
484483
} else {
485484
var contents = String.UnicodeScalarView()
486485
// always reserve a size larger than a small string
487-
contents.reserveCapacity(Swift.max(31, 1 + count + count >> 1))
486+
contents.reserveCapacity(Swift.max(_SmallString.capacity + 1, 1 + count + count >> 1))
488487
for c in String.UnicodeScalarView(self) {
489488
contents.append(c)
490489
}

test/stdlib/Span/BridgedStringUTF8ViewSpanTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ let strings = [
2828
"A long ASCII string exceeding 16 code units.",
2929
"🇯🇵",
3030
"🏂☃❅❆❄︎⛄️❄️",
31+
"",
3132
]
3233

3334
strings.forEach { expected in

0 commit comments

Comments
 (0)