@@ -30,22 +30,22 @@ public struct PatternTextPlaceholders: Equatable, ExpressibleByDictionaryLiteral
3030 }
3131
3232 @inlinable public init ( _ character: Character , where predicate: @escaping ( Character ) -> Bool ) {
33- self . option = . some( Some ( ( character, predicate) ) )
33+ self . option = . some( Some ( base : ( character, predicate) ) )
3434 }
3535
3636 @inlinable public init ( _ some: ( Character , ( Character ) -> Bool ) ) {
37- self . option = . some( Some ( some) )
37+ self . option = . some( Some ( base : some) )
3838 }
3939
4040 @inlinable public init ( _ many: [ Character : ( Character ) -> Bool ] ) {
41- self . option = . many( Many ( many) )
41+ self . option = . many( Many ( base : many) )
4242 }
4343
4444 @inlinable public init ( dictionaryLiteral elements: ( Character , ( Character ) -> Bool ) ... ) {
45- switch elements. count /* O(1) */ {
46- case 0 : self . init ( )
47- case 1 : self . init ( elements [ 0 ] )
48- default : self . init ( Dictionary ( elements , uniquingKeysWith : { $1 } ) ) }
45+ switch elements. count {
46+ case 1 : self . init ( elements [ 0 ] )
47+ case 2 ... : self . init ( Dictionary ( elements, uniquingKeysWith : { $1 } ) )
48+ default : self . init ( ) }
4949 }
5050
5151 //=------------------------------------------------------------------------=
@@ -68,36 +68,29 @@ public struct PatternTextPlaceholders: Equatable, ExpressibleByDictionaryLiteral
6868 case some( Some )
6969 case many( Many )
7070 }
71- }
72-
73- //=----------------------------------------------------------------------------=
74- // MARK: + Option(s)
75- //=----------------------------------------------------------------------------=
76-
77- extension PatternTextPlaceholders {
7871
7972 //*========================================================================*
8073 // MARK: * Some [...]
8174 //*========================================================================*
8275
8376 @usableFromInline struct Some : Equatable {
84-
77+
8578 //=--------------------------------------------------------------------=
8679
87- @usableFromInline let elements : ( Character , Predicate )
80+ @usableFromInline let base : ( Character , Predicate )
8881
8982 //=--------------------------------------------------------------------=
9083
91- @inlinable init ( _ elements : ( Character , Predicate ) ) {
92- self . elements = elements
84+ @inlinable init ( base : ( Character , Predicate ) ) {
85+ self . base = base
9386 }
9487
9588 @inlinable subscript( character: Character ) -> Predicate ? {
96- elements . 0 == character ? elements . 1 : nil
89+ base . 0 == character ? base . 1 : nil
9790 }
9891
9992 @inlinable static func == ( lhs: Self , rhs: Self ) -> Bool {
100- lhs. elements . 0 == rhs. elements . 0
93+ lhs. base . 0 == rhs. base . 0
10194 }
10295 }
10396
@@ -109,20 +102,20 @@ extension PatternTextPlaceholders {
109102
110103 //=--------------------------------------------------------------------=
111104
112- @usableFromInline let elements : [ Character : Predicate ]
105+ @usableFromInline let base : [ Character : Predicate ]
113106
114107 //=--------------------------------------------------------------------=
115108
116- @inlinable init ( _ elements : [ Character : Predicate ] ) {
117- self . elements = elements
109+ @inlinable init ( base : [ Character : Predicate ] ) {
110+ self . base = base
118111 }
119112
120113 @inlinable subscript( character: Character ) -> Predicate ? {
121- elements [ character]
114+ base [ character]
122115 }
123116
124117 @inlinable static func == ( lhs: Self , rhs: Self ) -> Bool {
125- lhs. elements . keys == rhs. elements . keys
118+ lhs. base . keys == rhs. base . keys
126119 }
127120 }
128121}
0 commit comments