Skip to content

Commit 995d8ce

Browse files
committed
style nits - capitalization, new line, truncatingIfNeeded
1 parent f2bd667 commit 995d8ce

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/LsbBitWriter.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public final class LsbBitWriter: BitWriter {
6161
- Note: If `bitsCount` is smaller than the actual amount of `number`'s bits than the `number` will be truncated to
6262
fit into `bitsCount` amount of bits.
6363
- Note: Bits of `number` are processed using the same bit-numbering scheme as of the writer (i.e. "LSB 0").
64-
- Note: this method is specifically useful when needing to write a UInt64 which can overflow and crash if converting to an Int when using the regular `write` method
64+
- Note: This method is specifically useful when needing to write a UInt64 which can overflow and crash if converting to an Int when using the regular `write` method
6565
*/
6666
public func write(unsignedNumber: UInt, bitsCount: Int) {
6767
var mask: UInt = 1
@@ -70,6 +70,7 @@ public final class LsbBitWriter: BitWriter {
7070
mask <<= 1
7171
}
7272
}
73+
7374
/**
7475
Writes `byte`, advancing by one BYTE position.
7576

Sources/MsbBitWriter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public final class MsbBitWriter: BitWriter {
6161
- Note: If `bitsCount` is smaller than the actual amount of `number`'s bits than the `number` will be truncated to
6262
fit into `bitsCount` amount of bits.
6363
- Note: Bits of `number` are processed using the same bit-numbering scheme as of the writer (i.e. "MSB 0").
64-
- Note: this method is specifically useful when needing to write a UInt64 which can overflow and crash if converting to an Int when using the regular `write` method
64+
- Note: This method is specifically useful when needing to write a UInt64 which can overflow and crash if converting to an Int when using the regular `write` method
6565
*/
6666
public func write(unsignedNumber: UInt, bitsCount: Int) {
67-
var mask: UInt = 1 << (UInt(bitsCount) - 1)
67+
var mask: UInt = 1 << (UInt(truncatingIfNeeded: bitsCount) - 1)
6868
for _ in 0..<bitsCount {
6969
self.write(bit: unsignedNumber & mask > 0 ? 1 : 0)
7070
mask >>= 1

0 commit comments

Comments
 (0)