Skip to content

Commit cbf7b79

Browse files
committed
Cleanup.
1 parent a847994 commit cbf7b79

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

Sources/DiffableTextKitXNumber/Reader/Attributes.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,29 @@ import DiffableTextKit
2020
// MARK: State
2121
//=------------------------------------------------------------------------=
2222

23-
@usableFromInline let map: Map
23+
@usableFromInline private(set) var map = Map(minimumCapacity: 13)
2424

2525
//=------------------------------------------------------------------------=
2626
// MARK: Initializers
2727
//=------------------------------------------------------------------------=
2828

2929
@inlinable init(_ local: Components) {
30-
var map = Map(minimumCapacity: 13)
3130
//=--------------------------------------=
3231
// (10) Digits
3332
//=--------------------------------------=
3433
for component in Digit.allCases {
35-
map[local.digits[component]] = .content
34+
self.map[local.digits[component]] = .content
3635
}
3736
//=--------------------------------------=
3837
// (1) Separators
3938
//=--------------------------------------=
40-
map[local.separators[.fraction]] = .removable
39+
self.map[local.separators[.fraction]] = .removable
4140
//=--------------------------------------=
4241
// (2) Signs
4342
//=--------------------------------------=
4443
for component in Sign.allCases {
45-
map[local.signs[component]] = .phantom.subtracting(.virtual)
44+
self.map[local.signs[component]] = .phantom.subtracting(.virtual)
4645
}
47-
//=--------------------------------------=
48-
// Return
49-
//=--------------------------------------=
50-
self.map = map
5146
}
5247

5348
//=------------------------------------------------------------------------=

Sources/DiffableTextKitXNumber/Reader/Reader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public final class Reader {
4040
@inlinable func number<T>(_ proposal: Proposal, as kind: T.Type)
4141
throws -> Number? where T: NumberTextKind {
4242
//=--------------------------------------=
43-
// Proposal
43+
// Edit
4444
//=--------------------------------------=
4545
var proposal = proposal
4646
translator.translateSingleSymbol(in: &proposal)
4747
let sign = components.consumeSingleSign(in: &proposal)
4848
//=--------------------------------------=
49-
// Number
49+
// Read
5050
//=--------------------------------------=
5151
guard var number = try Number(
5252
in: proposal.merged(),

Sources/DiffableTextKitXNumber/Reader/Translator.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,17 @@ import DiffableTextKit
2020
// MARK: State
2121
//=------------------------------------------------------------------------=
2222

23-
@usableFromInline let map: Map
23+
@usableFromInline private(set) var map = Map()
2424

2525
//=------------------------------------------------------------------------=
2626
// MARK: Initializers
2727
//=------------------------------------------------------------------------=
2828

2929
@inlinable init(_ local: Components) {
30-
var map = Map()
31-
//=--------------------------------------=
32-
// Reduce
33-
//=--------------------------------------=
34-
Self.reduce(into: &map, from: .ascii, to: local, all: \.digits, as: { $0 })
35-
Self.reduce(into: &map, from: .ascii, to: local, all: \.separators, as: { _ in .fraction })
36-
Self.reduce(into: &map, from: local, to: local, all: \.separators, as: { _ in .fraction })
37-
Self.reduce(into: &map, from: .ascii, to: local, all: \.signs, as: { $0 })
38-
//=--------------------------------------=
39-
// Return
40-
//=--------------------------------------=
41-
self.map = map
30+
Self.reduce(into: &self.map, from: .ascii, to: local, all: \.digits, as: { $0 })
31+
Self.reduce(into: &self.map, from: .ascii, to: local, all: \.separators, as: { _ in .fraction })
32+
Self.reduce(into: &self.map, from: local, to: local, all: \.separators, as: { _ in .fraction })
33+
Self.reduce(into: &self.map, from: .ascii, to: local, all: \.signs, as: { $0 })
4234
}
4335

4436
//=------------------------------------------------------------------------=

0 commit comments

Comments
 (0)