Skip to content

Commit e793e0e

Browse files
committed
Always ask Cocoa for terminated char*s
(cherry picked from commit b7ce22ba1525dccd47f4095a9bf8a640b238a5fa)
1 parent b6a614c commit e793e0e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/StringBridge.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ internal func _bridgeTagged(
351351
private func _NSStringASCIIPointer(_ str: _StringSelectorHolder) -> UnsafePointer<UInt8>? {
352352
// TODO(String bridging): Is there a better interface here? Ideally we'd be
353353
// able to ask for UTF8 rather than just ASCII
354-
return str._fastCStringContents(0)?._asUInt8
354+
//TODO(String bridging): Unconditionally asking for nul-terminated contents is
355+
// overly conservative and hurts perf with some NSStrings
356+
return str._fastCStringContents(1)?._asUInt8
355357
}
356358

357359
@_effects(readonly) // @opaque

0 commit comments

Comments
 (0)