Skip to content

Commit d8e9bff

Browse files
authored
Merge pull request #18039 from xedin/transparent-magnitude
[stdlib] Try to make `magnitude` transparent again by using `&+`
2 parents f0edc02 + 8f8a441 commit d8e9bff

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)