Skip to content

Commit c453d26

Browse files
authored
Merge pull request #160 from p-x9/fix/tuple-to-string-swift6
Fix conversion of char tuple to string
2 parents 096959c + 7697fb3 commit c453d26

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Sources/MachOKit/Extension/String+.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ extension String {
1414

1515
@_spi(Support)
1616
public init(tuple: CCharTuple16) {
17-
var buffer = tuple
18-
self = withUnsafePointer(to: &buffer.0) {
17+
self = withUnsafePointer(to: tuple) {
1918
let size = MemoryLayout<CCharTuple16>.size
2019
let data = Data(bytes: $0, count: size) + [0]
2120
return String(cString: data) ?? ""
@@ -29,8 +28,7 @@ extension String {
2928

3029
@_spi(Support)
3130
public init(tuple: CCharTuple32) {
32-
var buffer = tuple
33-
self = withUnsafePointer(to: &buffer.0) {
31+
self = withUnsafePointer(to: tuple) {
3432
let size = MemoryLayout<CCharTuple32>.size
3533
let data = Data(bytes: $0, count: size) + [0]
3634
return String(cString: data) ?? ""

0 commit comments

Comments
 (0)