Skip to content

Commit

Permalink
No NS-prefixed API
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Jan 8, 2025
1 parent 9cba0b8 commit da79548
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Sources/CacheAdvance/BigEndianHostSwappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Foundation
protocol BigEndianHostSwappable where Self: FixedWidthInteger {

/// Converts the big-endian value in x to the current endian format and returns the resulting value.
static func swapToHost(_ x: Self) -> Self
init(bigEndian value: Self)

/// The maximum representable integer in this type.
static var max: Self { get }
Expand All @@ -37,7 +37,7 @@ extension BigEndianHostSwappable {
let decodedSize = data.withUnsafeBytes {
$0.load(as: Self.self)
}
self = Self.swapToHost(decodedSize)
self = Self(bigEndian: decodedSize)
}

/// The length of a contiguous data blob required to store this type.
Expand Down
8 changes: 1 addition & 7 deletions Sources/CacheAdvance/UInt32+BigEndianHostSwappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@

import Foundation

extension UInt32: BigEndianHostSwappable {

static func swapToHost(_ x: UInt32) -> UInt32 {
NSSwapBigIntToHost(x)
}

}
extension UInt32: BigEndianHostSwappable {}
8 changes: 1 addition & 7 deletions Sources/CacheAdvance/UInt64+BigEndianHostSwappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@

import Foundation

extension UInt64: BigEndianHostSwappable {

static func swapToHost(_ x: UInt64) -> UInt64 {
NSSwapBigLongLongToHost(x)
}

}
extension UInt64: BigEndianHostSwappable {}
8 changes: 1 addition & 7 deletions Sources/CacheAdvance/UInt8+BigEndianHostSwappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@

import Foundation

extension UInt8: BigEndianHostSwappable {

static func swapToHost(_ x: UInt8) -> UInt8 {
x // UInt8 is 1-byte long, so local endianness does not affect storage of this type.
}

}
extension UInt8: BigEndianHostSwappable {}

0 comments on commit da79548

Please sign in to comment.