Skip to content

Commit a146f83

Browse files
committed
use hexString helper instead of String(format:)
1 parent 47bfeaa commit a146f83

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Sources/SwiftOCA/OCC/ControlDataTypes/BaseDataTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public struct OcaOrganizationID: Equatable, Hashable, Codable, Sendable, CustomS
526526
}
527527

528528
public var description: String {
529-
String(format: "%02X%02X%02X", id.0, id.1, id.2)
529+
[id.0, id.1, id.2].map { $0.hexString(width: 2, uppercase: true) }.joined()
530530
}
531531

532532
public init(_ hexString: String) throws {

Sources/SwiftOCA/OCC/ControlDataTypes/ModelDataTypes.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@ public struct OcaModelGUID: Hashable, Codable, Sendable, CustomStringConvertible
6161
public let modelCode: ModelCode
6262

6363
public var description: String {
64-
mfrCode.description + String(
65-
format: "%02X%02X%02X%02X",
66-
modelCode.0,
67-
modelCode.1,
68-
modelCode.2,
69-
modelCode.3
70-
)
64+
mfrCode.description + [modelCode.0, modelCode.1, modelCode.2, modelCode.3]
65+
.map { $0.hexString(width: 2, uppercase: true) }.joined()
7166
}
7267

7368
public init(reserved: OcaUint8 = 0, mfrCode: OcaOrganizationID, modelCode: ModelCode) {

0 commit comments

Comments
 (0)