@@ -24,6 +24,7 @@ pub use self::{
2424 walkers:: * ,
2525} ;
2626pub use either:: Either ;
27+ use indexmap:: IndexSet ;
2728pub use prisma_value:: PrismaValue ;
2829
2930use enumflags2:: { BitFlag , BitFlags } ;
@@ -57,7 +58,7 @@ pub struct SqlMetadata {
5758#[ derive( Serialize , Deserialize , Debug , Default , Clone ) ]
5859pub struct SqlSchema {
5960 /// Namespaces (schemas)
60- namespaces : Vec < String > ,
61+ namespaces : IndexSet < String > ,
6162 /// The schema's tables.
6263 tables : Vec < Table > ,
6364 /// The schema's enums.
@@ -185,10 +186,7 @@ impl SqlSchema {
185186
186187 /// Find a namespace by name.
187188 pub fn get_namespace_id ( & self , name : & str ) -> Option < NamespaceId > {
188- self . namespaces
189- . binary_search_by ( |ns_name| ns_name. as_str ( ) . cmp ( name) )
190- . ok ( )
191- . map ( |pos| NamespaceId ( pos as u32 ) )
189+ self . namespaces . get_index_of ( name) . map ( |pos| NamespaceId ( pos as u32 ) )
192190 }
193191
194192 /// The total number of indexes in the schema.
@@ -333,9 +331,8 @@ impl SqlSchema {
333331 }
334332
335333 pub fn push_namespace ( & mut self , name : String ) -> NamespaceId {
336- let id = NamespaceId ( self . namespaces . len ( ) as u32 ) ;
337- self . namespaces . push ( name) ;
338- id
334+ let ( id, _) = self . namespaces . insert_full ( name) ;
335+ NamespaceId ( id as u32 )
339336 }
340337
341338 pub fn push_table ( & mut self , name : String , namespace_id : NamespaceId , description : Option < String > ) -> TableId {
0 commit comments