@@ -14,7 +14,7 @@ use pyrefly_derive::TypeEq;
1414use pyrefly_derive:: Visit ;
1515use pyrefly_derive:: VisitMut ;
1616use ruff_python_ast:: name:: Name ;
17- use starlark_map:: ordered_map :: OrderedMap ;
17+ use starlark_map:: small_map :: SmallMap ;
1818use vec1:: Vec1 ;
1919
2020use crate :: types:: types:: Type ;
@@ -36,9 +36,7 @@ use crate::util::visit::VisitMut;
3636/// # here, `x` is still `Foo` but we also can narrow
3737/// # `x.foo`, `x.foo.bar`, and `x.baz`.
3838/// ```
39- #[ derive(
40- Debug , Clone , PartialEq , Eq , Visit , VisitMut , TypeEq , PartialOrd , Ord , Hash
41- ) ]
39+ #[ derive( Debug , Clone , PartialEq , Eq , Visit , VisitMut , TypeEq ) ]
4240pub struct TypeInfo {
4341 pub ty : Type ,
4442 pub attrs : NarrowedAttrs ,
@@ -94,8 +92,8 @@ impl Display for TypeInfo {
9492 }
9593}
9694
97- #[ derive( Debug , Clone , PartialEq , Eq , TypeEq , PartialOrd , Ord , Hash ) ]
98- pub struct NarrowedAttrs ( Option < OrderedMap < Name , NarrowedAttr > > ) ;
95+ #[ derive( Debug , Clone , PartialEq , Eq , TypeEq ) ]
96+ pub struct NarrowedAttrs ( Option < Box < SmallMap < Name , NarrowedAttr > > > ) ;
9997
10098impl NarrowedAttrs {
10199 fn new ( ) -> Self {
@@ -104,12 +102,12 @@ impl NarrowedAttrs {
104102
105103 fn add_narrow_mut ( & mut self , name : Name , more_names : & [ & Name ] , ty : Type ) {
106104 if self . 0 . is_none ( ) {
107- self . 0 = Some ( OrderedMap :: with_capacity ( 1 ) )
105+ self . 0 = Some ( Box :: new ( SmallMap :: with_capacity ( 1 ) ) )
108106 }
109107 match & mut self . 0 {
110108 None => unreachable ! ( "We just ensured that we have a map of attrs" ) ,
111- Some ( attrs) => {
112- let attr = match attrs. remove ( & name) {
109+ Some ( box attrs) => {
110+ let attr = match attrs. shift_remove ( & name) {
113111 Some ( attr) => attr. add_narrow ( more_names, ty) ,
114112 None => NarrowedAttr :: new ( more_names, ty) ,
115113 } ;
@@ -119,9 +117,9 @@ impl NarrowedAttrs {
119117 }
120118
121119 fn of_narrow ( name : Name , more_names : & [ & Name ] , ty : Type ) -> Self {
122- let mut attrs = OrderedMap :: with_capacity ( 1 ) ;
120+ let mut attrs = SmallMap :: with_capacity ( 1 ) ;
123121 attrs. insert ( name. clone ( ) , NarrowedAttr :: new ( more_names, ty) ) ;
124- Self ( Some ( attrs) )
122+ Self ( Some ( Box :: new ( attrs) ) )
125123 }
126124
127125 fn fmt_with_prefix ( & self , prefix : & mut Vec < String > , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -204,9 +202,7 @@ impl Display for NarrowedAttrs {
204202 }
205203}
206204
207- #[ derive(
208- Debug , Clone , Visit , VisitMut , PartialEq , Eq , TypeEq , PartialOrd , Ord , Hash
209- ) ]
205+ #[ derive( Debug , Clone , Visit , VisitMut , PartialEq , Eq , TypeEq ) ]
210206pub enum NarrowedAttr {
211207 Leaf ( Type ) ,
212208 WithRoot ( Type , NarrowedAttrs ) ,
0 commit comments