Skip to content

Commit

Permalink
remove Foundation dependency (String(format:))
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Jan 3, 2025
1 parent 8a23489 commit c0515c9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/IORingUtils/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ import IORing
import SocketAddress
import SystemPackage

private func byteToHex(_ byte: UInt8) -> String {
let hexAlphabet = Array("0123456789abcdef".utf8)
return String(unsafeUninitializedCapacity: 2) { ptr -> Int in
ptr[0] = hexAlphabet[Int(byte / 16)]
ptr[1] = hexAlphabet[Int(byte % 16)]
return 2
}
}

private func hexDescription(_ bytes: [UInt8]) -> String {
bytes.reduce("") { $0 + String(format: "%02x", $1) }
bytes.reduce("") { $0 + byteToHex($1) }
}

extension Message: CustomStringConvertible {
Expand Down

0 comments on commit c0515c9

Please sign in to comment.