[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:
Pavel Yaskevich
2018-07-18 00:25:10 -07:00
parent a9660c7bc5
commit 8f8a441c49

View File

@@ -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