Skip to content

Commit 890a7f2

Browse files
committed
[stdlib] Duration: add an initializer that takes low/high components
Having a direct initializer in the ABI is critically important — otherwise we wouldn’t be able to add back deployable conversion initializers in the future (without going through unnecessary overhead).
1 parent e0a411a commit 890a7f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/core/Duration.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ public struct Duration: Sendable {
4242
@usableFromInline
4343
internal var _high: Int64
4444

45+
@inlinable
46+
internal init(_low: UInt64, high: Int64) {
47+
self._low = _low
48+
self._high = high
49+
}
50+
4551
internal init(_attoseconds: _Int128) {
46-
self._low = _attoseconds.low
47-
self._high = _attoseconds.high
52+
self.init(_low: _attoseconds.low, high: _attoseconds.high)
4853
}
4954

5055
/// Construct a `Duration` by adding attoseconds to a seconds value.

0 commit comments

Comments
 (0)