Skip to content

Commit b9f9cd4

Browse files
committed
Specify correctly 4.2 version of _compiler_ in ByteReader's performance workarounds
1 parent 9a19a8d commit b9f9cd4

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Sources/ByteReader.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ByteReader {
2323
- Note: It generally means that all bytes have been read.
2424
*/
2525
public var isFinished: Bool {
26-
#if swift(>=4.2)
26+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
2727
return { (data: Data, offset: Int) -> Bool in
2828
data.endIndex <= offset
2929
} (self.data, self.offset)
@@ -35,7 +35,7 @@ public class ByteReader {
3535

3636
/// Amount of bytes left to read.
3737
public var bytesLeft: Int {
38-
#if swift(>=4.2)
38+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
3939
return { (data: Data, offset: Int) -> Int in
4040
self.data.endIndex - self.offset
4141
} (self.data, self.offset)
@@ -46,7 +46,7 @@ public class ByteReader {
4646

4747
/// Amount of bytes that were already read.
4848
public var bytesRead: Int {
49-
#if swift(>=4.2)
49+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
5050
return { (data: Data, offset: Int) -> Int in
5151
return offset - data.startIndex
5252
} (self.data, self.offset)
@@ -68,7 +68,7 @@ public class ByteReader {
6868
- Precondition: There MUST be enough data left.
6969
*/
7070
public func byte() -> UInt8 {
71-
#if swift(>=4.2)
71+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
7272
return { (data: Data, offset: inout Int) -> UInt8 in
7373
precondition(offset < data.endIndex)
7474
defer { offset += 1 }
@@ -90,7 +90,7 @@ public class ByteReader {
9090
public func bytes(count: Int) -> [UInt8] {
9191
precondition(count >= 0)
9292
precondition(bytesLeft >= count)
93-
#if swift(>=4.2)
93+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
9494
return { (data: Data, offset: inout Int) -> [UInt8] in
9595
defer { offset += count }
9696
return data[offset..<offset + count].toArray(type: UInt8.self, count: count)
@@ -112,7 +112,7 @@ public class ByteReader {
112112
precondition(bytesLeft >= count)
113113
// TODO: If uintX() could be force inlined or something in the future then probably it would make sense
114114
// to use them for `count` == 2, 4 or 8.
115-
#if swift(>=4.2)
115+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
116116
return { (data: Data, offset: inout Int) -> Int in
117117
var result = 0
118118
for i in 0..<count {
@@ -138,7 +138,7 @@ public class ByteReader {
138138
*/
139139
public func uint64() -> UInt64 {
140140
precondition(bytesLeft >= 8)
141-
#if swift(>=4.2)
141+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
142142
return { (data: Data, offset: inout Int) -> UInt64 in
143143
defer { offset += 8 }
144144
return data[offset..<offset + 8].to(type: UInt64.self)
@@ -161,7 +161,7 @@ public class ByteReader {
161161
public func uint64(fromBytes count: Int) -> UInt64 {
162162
precondition(0...8 ~= count)
163163
precondition(bytesLeft >= count)
164-
#if swift(>=4.2)
164+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
165165
return { (data: Data, offset: inout Int) -> UInt64 in
166166
var result = 0 as UInt64
167167
for i in 0..<count {
@@ -187,7 +187,7 @@ public class ByteReader {
187187
*/
188188
public func uint32() -> UInt32 {
189189
precondition(bytesLeft >= 4)
190-
#if swift(>=4.2)
190+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
191191
return { (data: Data, offset: inout Int) -> UInt32 in
192192
defer { offset += 4 }
193193
return data[offset..<offset + 4].to(type: UInt32.self)
@@ -210,7 +210,7 @@ public class ByteReader {
210210
public func uint32(fromBytes count: Int) -> UInt32 {
211211
precondition(0...4 ~= count)
212212
precondition(bytesLeft >= count)
213-
#if swift(>=4.2)
213+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
214214
return { (data: Data, offset: inout Int) -> UInt32 in
215215
var result = 0 as UInt32
216216
for i in 0..<count {
@@ -236,7 +236,7 @@ public class ByteReader {
236236
*/
237237
public func uint16() -> UInt16 {
238238
precondition(bytesLeft >= 2)
239-
#if swift(>=4.2)
239+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
240240
return { (data: Data, offset: inout Int) -> UInt16 in
241241
defer { offset += 2 }
242242
return data[offset..<offset + 2].to(type: UInt16.self)
@@ -259,7 +259,7 @@ public class ByteReader {
259259
public func uint16(fromBytes count: Int) -> UInt16 {
260260
precondition(0...2 ~= count)
261261
precondition(bytesLeft >= count)
262-
#if swift(>=4.2)
262+
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
263263
return { (data: Data, offset: inout Int) -> UInt16 in
264264
var result = 0 as UInt16
265265
for i in 0..<count {

0 commit comments

Comments
 (0)