Skip to content

Commit 8f8a441

Browse files
committed
[stdlib] Try to make magnitude transparent again by using &+
Improvements from SE-0213 made constant propagation more precise but, as a side-effect, resulted in more false positives, to mitigate that `magnitude` has marked as `@inline(__always)` but it could be made transparent again by using `&+` operator.
1 parent a9660c7 commit 8f8a441

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

stdlib/public/core/Integers.swift.gyb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,12 +3592,10 @@ ${assignmentOperatorComment(x.operator, True)}
35923592
/// to find an absolute value. In addition, because `abs(_:)` always returns
35933593
/// a value of the same type, even in a generic context, using the function
35943594
/// instead of the `magnitude` property is encouraged.
3595+
@_transparent
35953596
public var magnitude: U${Self} {
3596-
@inline(__always)
3597-
get {
3598-
let base = U${Self}(_value)
3599-
return self < (0 as ${Self}) ? ~base + 1 : base
3600-
}
3597+
let base = U${Self}(_value)
3598+
return self < (0 as ${Self}) ? ~base &+ 1 : base
36013599
}
36023600
% end
36033601

0 commit comments

Comments
 (0)