Skip to content

Commit 85180c2

Browse files
committed
Added WebAssembly support
1 parent d61fcc0 commit 85180c2

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Sources/Data.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ internal extension Data {
1414

1515
// stored in heap, can reuse buffer
1616
if count > Data.inlineBufferSize {
17-
1817
return withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
1918
Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: buffer.baseAddress!.advanced(by: range.lowerBound)),
2019
count: range.count,
2120
deallocator: .none)
2221
}
23-
2422
} else {
25-
2623
// stored in stack, must copy
2724
return subdata(in: range)
2825
}
@@ -33,7 +30,6 @@ internal extension Data {
3330
}
3431

3532
func suffixCheckingBounds(from start: Int) -> Data {
36-
3733
if count > start {
3834
return Data(suffix(from: start))
3935
} else {
@@ -54,9 +50,11 @@ private extension Data {
5450
#if arch(x86_64) || arch(arm64) || arch(arm64_32) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
5551
typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
5652
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) //len //enum
57-
#elseif arch(i386) || arch(arm)
53+
#elseif arch(i386) || arch(arm) || arch(wasm32)
5854
typealias Buffer = (UInt8, UInt8, UInt8, UInt8,
5955
UInt8, UInt8)
56+
#else
57+
#error("Platform not supported")
6058
#endif
6159

6260
return MemoryLayout<Buffer>.size

0 commit comments

Comments
 (0)