mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -3592,12 +3592,10 @@ ${assignmentOperatorComment(x.operator, True)}
|
||||
/// to find an absolute value. In addition, because `abs(_:)` always returns
|
||||
/// a value of the same type, even in a generic context, using the function
|
||||
/// instead of the `magnitude` property is encouraged.
|
||||
@_transparent
|
||||
public var magnitude: U${Self} {
|
||||
@inline(__always)
|
||||
get {
|
||||
let base = U${Self}(_value)
|
||||
return self < (0 as ${Self}) ? ~base + 1 : base
|
||||
}
|
||||
let base = U${Self}(_value)
|
||||
return self < (0 as ${Self}) ? ~base &+ 1 : base
|
||||
}
|
||||
% end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user