@@ -52,27 +52,27 @@ extension Character {
5252 var firstScalar: UnicodeScalar { return unicodeScalars.first! }
5353}
5454
55- % Properties = { "Alphanumeric": "alphanumerics", \
56- % "Capitalized": "capitalizedLetters", \
57- % "Control": "controlCharacters", \
58- % "Decimal": "decimalDigits", \
59- % "Letter": "letters", \
60- % "Lowercase": "lowercaseLetters", \
61- % "Uppercase": "uppercaseLetters", \
62- % "Newline": "newlines", \
63- % "Whitespace": "whitespaces", \
64- % "Punctuation": "punctuationCharacters" \
65- % }
55+ % Properties = [ ( "Alphanumeric", "alphanumerics"),
56+ % ( "Capitalized", "capitalizedLetters"),
57+ % ( "Control", "controlCharacters"),
58+ % ( "Decimal", "decimalDigits"),
59+ % ( "Letter", "letters"),
60+ % ( "Lowercase", "lowercaseLetters"),
61+ % ( "Uppercase", "uppercaseLetters"),
62+ % ( "Newline", "newlines"),
63+ % ( "Whitespace", "whitespaces"),
64+ % ( "Punctuation", "punctuationCharacters")
65+ % ]
6666
6767// Fetch the CharacterSet for every call
68- % for Property, Set in Properties.items() :
68+ % for Property, Set in Properties:
6969func is${Property}(_ c: Character) -> Bool {
7070 return CharacterSet.${Set}.contains(c.firstScalar)
7171}
7272% end
7373
7474// Stash the set
75- % for Property, Set in Properties.items() :
75+ % for Property, Set in Properties:
7676let ${Set} = CharacterSet.${Set}
7777func is${Property}Stashed(_ c: Character) -> Bool {
7878 return ${Set}.contains(c.firstScalar)
@@ -81,13 +81,13 @@ func is${Property}Stashed(_ c: Character) -> Bool {
8181
8282func setupStash() {
8383 blackHole(workload)
84- % for Property, Set in Properties.items() :
84+ % for Property, Set in Properties:
8585 blackHole(${Set})
8686% end
8787}
8888
8989// Memoize the stashed set
90- % for Property, Set in Properties.items() :
90+ % for Property, Set in Properties:
9191var ${Set}Memo = Set<UInt32>()
9292func is${Property}StashedMemo(_ c: Character) -> Bool {
9393 let scalar = c.firstScalar
@@ -102,7 +102,7 @@ func is${Property}StashedMemo(_ c: Character) -> Bool {
102102
103103func setupMemo() {
104104 blackHole(workload)
105- % for Property, Set in Properties.items() :
105+ % for Property, Set in Properties:
106106 blackHole(${Set}Memo)
107107% end
108108}
@@ -130,7 +130,7 @@ func precompute(_ charSet: CharacterSet, capacity: Int) -> Set<UInt32> {
130130 capitalizedLetters=31
131131 )
132132}%
133- % for Property, Set in Properties.items() :
133+ % for Property, Set in Properties:
134134var ${Set}Precomputed: Set<UInt32> =
135135 precompute(${Set}, capacity: ${precomputed_capacity[Set]})
136136func is${Property}Precomputed(_ c: Character) -> Bool {
@@ -140,7 +140,7 @@ func is${Property}Precomputed(_ c: Character) -> Bool {
140140
141141func setupPrecomputed() {
142142 blackHole(workload)
143- % for Property, Set in Properties.items() :
143+ % for Property, Set in Properties:
144144 blackHole(${Set}Precomputed)
145145%#// print("${Set}: \(${Set}Precomputed.count)")
146146% end
@@ -171,7 +171,7 @@ let workload = """
171171public func run_CharacterPropertiesFetch(_ N: Int) {
172172 for _ in 1...N {
173173 for c in workload {
174- % for Property, Set in Properties.items() :
174+ % for Property, Set in Properties:
175175 blackHole(is${Property}(c))
176176 % end
177177 }
@@ -182,7 +182,7 @@ public func run_CharacterPropertiesFetch(_ N: Int) {
182182public func run_CharacterPropertiesStashed(_ N: Int) {
183183 for _ in 1...N {
184184 for c in workload {
185- % for Property, Set in Properties.items() :
185+ % for Property, Set in Properties:
186186 blackHole(is${Property}Stashed(c))
187187 % end
188188 }
@@ -193,7 +193,7 @@ public func run_CharacterPropertiesStashed(_ N: Int) {
193193public func run_CharacterPropertiesStashedMemo(_ N: Int) {
194194 for _ in 1...N {
195195 for c in workload {
196- % for Property, Set in Properties.items() :
196+ % for Property, Set in Properties:
197197 blackHole(is${Property}StashedMemo(c))
198198 % end
199199 }
@@ -204,7 +204,7 @@ public func run_CharacterPropertiesStashedMemo(_ N: Int) {
204204public func run_CharacterPropertiesPrecomputed(_ N: Int) {
205205 for _ in 1...N {
206206 for c in workload {
207- % for Property, Set in Properties.items() :
207+ % for Property, Set in Properties:
208208 blackHole(is${Property}Precomputed(c))
209209 % end
210210 }
0 commit comments