Skip to content

Commit 7957075

Browse files
committed
Removed redundant calculation on NumericTextStyles/Adapter/update(_:).
1 parent ccdde13 commit 7957075

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Sources/DiffableTextStylesXNumeric/Format.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ extension NumericTextFormat {
7878
try parseStrategy.parse(characters)
7979
}
8080

81-
//=------------------------------------------------------------------------=
82-
// MARK: Autocorrect
83-
//=------------------------------------------------------------------------=
84-
85-
/// The format should always round towards zero.
86-
@inlinable func autocorrect() -> Self {
87-
self.rounded(.towardZero)
88-
}
89-
9081
//=------------------------------------------------------------------------=
9182
// MARK: Transformations
9283
//=------------------------------------------------------------------------=

Sources/DiffableTextStylesXNumeric/Helpers/Adapter.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ import Foundation
2828
// MARK: Initializers
2929
//=------------------------------------------------------------------------=
3030

31-
@inlinable init(_ format: Format) {
32-
self.format = format.autocorrect()
33-
self.scheme = self.format.scheme()
31+
@inlinable init(unchecked: Format) {
32+
self.format = unchecked
33+
self.scheme = unchecked.scheme()
34+
}
35+
36+
@inlinable @inline(__always) init(_ format: Format) {
37+
self.init(unchecked: format.rounded(.towardZero))
3438
}
3539

3640
//=------------------------------------------------------------------------=
@@ -50,7 +54,7 @@ import Foundation
5054
//=------------------------------------------------------------------------=
5155

5256
@inlinable mutating func update(_ locale: Locale) {
53-
self = Self(format.locale(locale))
57+
self = Self(unchecked: format.locale(locale))
5458
}
5559

5660
//=------------------------------------------------------------------------=

0 commit comments

Comments
 (0)