Skip to content

Commit 2d70a99

Browse files
committed
refactor: some methods make always inline
1 parent 49103c7 commit 2d70a99

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/BinaryReader/BinaryReader.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ public struct BinaryReader {
6363
let b = bytes(count: 1)
6464
return b.first!
6565
}
66+
@inline(__always)
6667
public mutating func int8() -> Int8 {
6768
return .init(bitPattern: uint8())
6869
}
70+
@inline(__always)
6971
public mutating func bool() -> Bool {
7072
return uint8() != 0
7173
}
@@ -75,6 +77,7 @@ public struct BinaryReader {
7577
let v = UInt16(b[0]) | UInt16(b[1]) << 8
7678
return v
7779
}
80+
@inline(__always)
7881
public mutating func int16() -> Int16 {
7982
return .init(bitPattern: uint16())
8083
}
@@ -83,6 +86,7 @@ public struct BinaryReader {
8386
let b = endianConvert(from: bytes(count: 4))
8487
return UInt32(b[0]) | UInt32(b[1]) << 8 | UInt32(b[2]) << 16 | UInt32(b[3]) << 24
8588
}
89+
@inline(__always)
8690
public mutating func int32() -> Int32 {
8791
return .init(bitPattern: uint32())
8892
}
@@ -93,14 +97,17 @@ public struct BinaryReader {
9397
let upper: UInt64 = UInt64(b[4]) << 32 | UInt64(b[5]) << 40 | UInt64(b[6]) << 48 | UInt64(b[7]) << 56
9498
return lower | upper
9599
}
100+
@inline(__always)
96101
public mutating func int64() -> Int64 {
97102
return .init(bitPattern: uint64())
98103
}
99104

105+
@inline(__always)
100106
public mutating func float32() -> Float32 {
101107
return .init(bitPattern: uint32())
102108
}
103109

110+
@inline(__always)
104111
public mutating func float64() -> Float64 {
105112
return .init(bitPattern: uint64())
106113
}

0 commit comments

Comments
 (0)