@@ -133,20 +133,16 @@ impl CharacterDefinition {
133133 }
134134}
135135
136- #[ derive( Debug ) ]
137- struct CharacterAttributes ( HashSet < ( char , Attribute ) > ) ;
136+ #[ derive( Debug , Default ) ]
137+ struct CharacterAttributes ( HashMap < Attribute , HashSet < char > > ) ;
138138
139139impl CharacterAttributes {
140140 fn new ( ) -> Self {
141- Self ( HashSet :: new ( ) )
142- }
143-
144- fn insert ( & mut self , c : char , attribute : Attribute ) {
145- self . 0 . insert ( ( c, attribute) ) ;
141+ Self ( HashMap :: new ( ) )
146142 }
147143
148- fn contains ( & self , c : char , attribute : Attribute ) -> bool {
149- self . 0 . contains ( & ( c , attribute) )
144+ fn insert ( & mut self , attribute : Attribute , c : char ) {
145+ self . 0 . entry ( attribute) . or_default ( ) . insert ( c ) ;
150146 }
151147}
152148
@@ -190,15 +186,15 @@ impl TranslationTable {
190186 let translation =
191187 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
192188 character_definitions. insert ( * character, translation) ;
193- character_attributes. insert ( * character , Attribute :: Space ) ;
189+ character_attributes. insert ( Attribute :: Space , * character ) ;
194190 }
195191 Rule :: Punctuation {
196192 character, dots, ..
197193 } => {
198194 let translation =
199195 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
200196 character_definitions. insert ( * character, translation) ;
201- character_attributes. insert ( * character , Attribute :: Punctuation ) ;
197+ character_attributes. insert ( Attribute :: Punctuation , * character ) ;
202198 }
203199 Rule :: Digit {
204200 character, dots, ..
@@ -209,39 +205,39 @@ impl TranslationTable {
209205 let translation =
210206 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
211207 character_definitions. insert ( * character, translation) ;
212- character_attributes. insert ( * character , Attribute :: Digit ) ;
208+ character_attributes. insert ( Attribute :: Digit , * character ) ;
213209 }
214210 Rule :: Letter {
215211 character, dots, ..
216212 } => {
217213 let translation =
218214 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
219215 character_definitions. insert ( * character, translation) ;
220- character_attributes. insert ( * character , Attribute :: Letter ) ;
216+ character_attributes. insert ( Attribute :: Letter , * character ) ;
221217 }
222218 Rule :: Lowercase {
223219 character, dots, ..
224220 } => {
225221 let translation =
226222 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
227223 character_definitions. insert ( * character, translation) ;
228- character_attributes. insert ( * character , Attribute :: Lowercase ) ;
224+ character_attributes. insert ( Attribute :: Lowercase , * character ) ;
229225 }
230226 Rule :: Uppercase {
231227 character, dots, ..
232228 } => {
233229 let translation =
234230 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
235231 character_definitions. insert ( * character, translation) ;
236- character_attributes. insert ( * character , Attribute :: Uppercase ) ;
232+ character_attributes. insert ( Attribute :: Uppercase , * character ) ;
237233 }
238234 Rule :: Sign {
239235 character, dots, ..
240236 } => {
241237 let translation =
242238 Translation :: new ( character. to_string ( ) , dots_to_unicode ( dots) , 1 ) ;
243239 character_definitions. insert ( * character, translation) ;
244- character_attributes. insert ( * character , Attribute :: Sign ) ;
240+ character_attributes. insert ( Attribute :: Sign , * character ) ;
245241 }
246242 Rule :: Math {
247243 character, dots, ..
0 commit comments