@@ -6,6 +6,8 @@ use std::collections::HashMap;
6
6
use std:: collections:: HashSet ;
7
7
use std:: sync:: Arc ;
8
8
9
+ use unicase:: UniCase ;
10
+
9
11
use super :: NameOrId ;
10
12
use crate :: card:: CardQueue ;
11
13
use crate :: card:: CardType ;
@@ -83,7 +85,7 @@ struct Context<'a> {
83
85
84
86
struct DeckIdsByNameOrId {
85
87
ids : HashSet < DeckId > ,
86
- names : HashMap < String , DeckId > ,
88
+ names : HashMap < UniCase < String > , DeckId > ,
87
89
default : Option < DeckId > ,
88
90
}
89
91
@@ -146,10 +148,10 @@ impl Duplicate {
146
148
147
149
impl DeckIdsByNameOrId {
148
150
fn new ( col : & mut Collection , default : & NameOrId ) -> Result < Self > {
149
- let names: HashMap < String , DeckId > = col
151
+ let names: HashMap < UniCase < String > , DeckId > = col
150
152
. get_all_normal_deck_names ( false ) ?
151
153
. into_iter ( )
152
- . map ( |( id, name) | ( name, id) )
154
+ . map ( |( id, name) | ( UniCase :: new ( name) , id) )
153
155
. collect ( ) ;
154
156
let ids = names. values ( ) . copied ( ) . collect ( ) ;
155
157
let mut new = Self {
@@ -166,13 +168,13 @@ impl DeckIdsByNameOrId {
166
168
match name_or_id {
167
169
_ if * name_or_id == NameOrId :: default ( ) => self . default ,
168
170
NameOrId :: Id ( id) => self . ids . get ( & DeckId ( * id) ) . copied ( ) ,
169
- NameOrId :: Name ( name) => self . names . get ( name) . copied ( ) ,
171
+ NameOrId :: Name ( name) => self . names . get ( & UniCase :: new ( name. to_string ( ) ) ) . copied ( ) ,
170
172
}
171
173
}
172
174
173
175
fn insert ( & mut self , deck_id : DeckId , name : String ) {
174
176
self . ids . insert ( deck_id) ;
175
- self . names . insert ( name, deck_id) ;
177
+ self . names . insert ( UniCase :: new ( name) , deck_id) ;
176
178
}
177
179
}
178
180
0 commit comments