diff --git a/Sources/ZIPFoundation/Data+Serialization.swift b/Sources/ZIPFoundation/Data+Serialization.swift index 12340f90..59a8db15 100644 --- a/Sources/ZIPFoundation/Data+Serialization.swift +++ b/Sources/ZIPFoundation/Data+Serialization.swift @@ -29,12 +29,9 @@ extension Data { } func scanValue(start: Int) -> T { - let subdata = self.subdata(in: start...size) - #if swift(>=5.0) - return subdata.withUnsafeBytes { $0.load(as: T.self) } - #else - return subdata.withUnsafeBytes { $0.pointee } - #endif + return self.withUnsafeBytes { + $0.loadUnaligned(fromByteOffset: start, as: T.self) + } } static func readStruct(from file: FILEPointer, at offset: UInt64)