File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,17 @@ public struct Alignment: Comparable, Hashable {
27
27
///
28
28
/// An n-byte alignment contains log-base-two-many least-significant zeros.
29
29
public func log2( ) -> UInt32 {
30
+ guard !isZero else { return 0 }
30
31
return 31 - UInt32( self . rawValue. leadingZeroBitCount)
31
32
}
32
33
33
34
/// Returns the log-base-two value of this alignment as a 64-bit integer.
34
35
///
35
36
/// An n-byte alignment contains log-base-two-many least-significant zeros.
36
37
public func log2( ) -> UInt64 {
37
- return 63 - UInt64( self . rawValue. leadingZeroBitCount)
38
+ guard !isZero else { return 0 }
39
+ // rawValue is only 32 bits
40
+ return 31 - UInt64( self . rawValue. leadingZeroBitCount)
38
41
}
39
42
40
43
/// Returns the alignment of a pointer which points to the given number of
You can’t perform that action at this time.
0 commit comments