Skip to content

Commit 1b60cc7

Browse files
committed
Cleanup.
1 parent c01616f commit 1b60cc7

File tree

5 files changed

+32
-27
lines changed

5 files changed

+32
-27
lines changed

Sources/DiffableTextKit/Models/Context.swift

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public struct Context<Style: DiffableTextStyle> {
6161
// MARK: Transformation
6262
//=------------------------------------------------------------------------=
6363

64-
/// Transforms this instance with copy-on-write behavior.
64+
/// Writes to storage with copy-on-write behavior.
6565
@inlinable mutating func write(_ write: (Storage) -> Void) {
6666
//=--------------------------------------=
6767
// Unique
@@ -111,49 +111,57 @@ public struct Context<Style: DiffableTextStyle> {
111111
// MARK: Accessors
112112
//=----------------------------------------------------------------------------=
113113

114-
public extension Context {
114+
extension Context {
115115

116116
//=------------------------------------------------------------------------=
117117
// MARK: 1st
118118
//=------------------------------------------------------------------------=
119119

120-
@inlinable internal var status: Status {
120+
@inlinable @inline(__always)
121+
var status: Status {
121122
_storage.status
122123
}
123124

124-
@inlinable internal var layout: Layout {
125+
@inlinable @inline(__always)
126+
var layout: Layout {
125127
_storage.layout
126128
}
127129

128130
//=------------------------------------------------------------------------=
129131
// MARK: 2nd
130132
//=------------------------------------------------------------------------=
131133

132-
@inlinable var style: Style {
134+
@inlinable @inline(__always)
135+
public var style: Style {
133136
status.style
134137
}
135138

136-
@inlinable var value: Value {
139+
@inlinable @inline(__always)
140+
public var value: Value {
137141
status.value
138142
}
139143

140-
@inlinable var focus: Focus {
144+
@inlinable @inline(__always)
145+
public var focus: Focus {
141146
status.focus
142147
}
143148

144149
//=------------------------------------------------------------------------=
145150
// MARK: 3rd
146151
//=------------------------------------------------------------------------=
147152

148-
@inlinable var snapshot: Snapshot {
153+
@inlinable @inline(__always)
154+
public var snapshot: Snapshot {
149155
layout.snapshot
150156
}
151157

152-
@inlinable var text: String {
158+
@inlinable @inline(__always)
159+
public var text: String {
153160
layout.snapshot.characters
154161
}
155162

156-
@inlinable func selection<T>(as type: Position<T>.Type =
163+
@inlinable @inline(__always)
164+
public func selection<T>(as position: Position<T>.Type =
157165
Position<T>.self) -> Range<T.Position> where T: Offset {
158166
layout.selection().range
159167
}
@@ -197,13 +205,13 @@ extension Context {
197205
// MARK: Transformations
198206
//=----------------------------------------------------------------------------=
199207

200-
public extension Context {
208+
extension Context {
201209

202210
//=------------------------------------------------------------------------=
203211
// MARK: Status
204212
//=------------------------------------------------------------------------=
205213

206-
@inlinable mutating func merge(_ status: Status) -> Update {
214+
@inlinable public mutating func merge(_ status: Status) -> Update {
207215
//=--------------------------------------=
208216
// Update
209217
//=--------------------------------------=
@@ -227,7 +235,7 @@ public extension Context {
227235
// MARK: Characters
228236
//=------------------------------------------------------------------------=
229237

230-
@inlinable mutating func merge<T>(_ characters: String,
238+
@inlinable public mutating func merge<T>(_ characters: String,
231239
in range: Range<T.Position>) throws -> Update where T: Offset {
232240
let previous = value
233241
//=--------------------------------------=
@@ -251,7 +259,7 @@ public extension Context {
251259
// MARK: Selection
252260
//=------------------------------------------------------------------------=
253261

254-
@inlinable mutating func merge<T>(
262+
@inlinable public mutating func merge<T>(
255263
selection: Range<T.Position>,
256264
momentums: Bool) -> Update where T: Offset {
257265
//=--------------------------------------=

Sources/DiffableTextKitXNumber/Aliases.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,3 @@ extension _OptionalNumberTextStyle where Format: NumberTextFormatXCurrencyable {
3838
extension _OptionalNumberTextStyle where Format: NumberTextFormatXPercentable {
3939
public typealias Percent = _OptionalNumberTextStyle<Format.Percent>
4040
}
41-
42-
//*============================================================================*
43-
// MARK: Helpers
44-
//*============================================================================*
45-
46-
public typealias NFSC = NumberFormatStyleConfiguration
47-
public typealias CFSC = CurrencyFormatStyleConfiguration

Sources/DiffableTextKitXNumber/Format.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ FormatInput: DiffableTextKitXNumber.NumberTextValue {
1818
associatedtype NumberTextRoundingIncrement
1919
associatedtype NumberTextSign: NumberTextFormatXSignRepresentable
2020
associatedtype NumberTextScheme: DiffableTextKitXNumber.NumberTextScheme
21+
22+
typealias NFSC = NumberFormatStyleConfiguration
23+
typealias CFSC = CurrencyFormatStyleConfiguration
2124

2225
//=------------------------------------------------------------------------=
2326
// MARK: State

Sources/DiffableTextKitXNumber/Models/Precision.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Foundation
1616

1717
public struct NumberTextPrecision<Value: NumberTextValue>: Equatable {
1818
@usableFromInline typealias Name = _Precision
19+
@usableFromInline typealias Mode = NumberFormatStyleConfiguration.Precision
1920

2021
//=------------------------------------------------------------------------=
2122
// MARK: State
@@ -87,19 +88,19 @@ public struct NumberTextPrecision<Value: NumberTextValue>: Equatable {
8788
// MARK: Utilities
8889
//=------------------------------------------------------------------------=
8990

90-
@inlinable func inactive() -> NFSC.Precision {
91+
@inlinable func inactive() -> Mode {
9192
.integerAndFractionLength(
9293
integerLimits: integer.lowerBound ... Int.max,
9394
fractionLimits: fraction.lowerBound ... Int.max)
9495
}
9596

96-
@inlinable func active() -> NFSC.Precision {
97+
@inlinable func active() -> Mode {
9798
.integerAndFractionLength(
9899
integerLimits: Name.lower.integer ... integer.upperBound,
99100
fractionLimits: Name.lower.fraction ... fraction.upperBound)
100101
}
101102

102-
@inlinable func interactive(_ count: Count) -> NFSC.Precision {
103+
@inlinable func interactive(_ count: Count) -> Mode {
103104
.integerAndFractionLength(
104105
integerLimits: max(Name.lower.integer, count.integer) ... count.integer,
105106
fractionLimits: max(Name.lower.fraction, count.fraction) ... count.fraction)

Sources/DiffableTextKitXNumber/Value+Floats.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Foundation
1313
// MARK: Declaration
1414
//*============================================================================*
1515

16-
private protocol _Value:
16+
private protocol _Float:
1717
NumberTextValueXSigned,
1818
NumberTextValueXFloatingPoint,
1919
NumberTextValueXNumberable,
@@ -24,7 +24,7 @@ NumberTextValueXPercentable { }
2424
// MARK: Decimal
2525
//*============================================================================*
2626

27-
extension Decimal: _Value {
27+
extension Decimal: _Float {
2828
public typealias NumberTextStyle = _NumberTextStyle<FormatStyle>
2929

3030
//=------------------------------------------------------------------------=
@@ -40,7 +40,7 @@ extension Decimal: _Value {
4040
// MARK: Double
4141
//*============================================================================*
4242

43-
extension Double: _Value {
43+
extension Double: _Float {
4444
public typealias NumberTextStyle = _NumberTextStyle<FloatingPointFormatStyle<Self>>
4545

4646
//=------------------------------------------------------------------------=

0 commit comments

Comments
 (0)