@@ -10,7 +10,7 @@ use crate::common::{
1010use crate :: {
1111 builtins:: { PyInt , PyStr , PyStrRef } ,
1212 convert:: ToPyObject ,
13- AsObject , Py , PyObject , PyObjectRef , PyRefExact , PyResult , VirtualMachine ,
13+ AsObject , Py , PyExact , PyObject , PyObjectRef , PyRefExact , PyResult , VirtualMachine ,
1414} ;
1515use num_traits:: ToPrimitive ;
1616use std:: { fmt, mem:: size_of, ops:: ControlFlow } ;
@@ -686,39 +686,39 @@ pub trait DictKey {
686686/// to index dictionaries.
687687impl DictKey for PyObject {
688688 type Owned = PyObjectRef ;
689- #[ inline]
689+ #[ inline( always ) ]
690690 fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
691691 self . to_owned ( )
692692 }
693-
693+ # [ inline ( always ) ]
694694 fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
695695 self . hash ( vm)
696696 }
697-
697+ # [ inline ( always ) ]
698698 fn key_is ( & self , other : & PyObject ) -> bool {
699699 self . is ( other)
700700 }
701-
701+ # [ inline ( always ) ]
702702 fn key_eq ( & self , vm : & VirtualMachine , other_key : & PyObject ) -> PyResult < bool > {
703703 vm. identical_or_equal ( self , other_key)
704704 }
705-
705+ # [ inline ]
706706 fn key_as_isize ( & self , vm : & VirtualMachine ) -> PyResult < isize > {
707707 vm. to_index ( self ) ?. try_to_primitive ( vm)
708708 }
709709}
710710
711711impl DictKey for Py < PyStr > {
712712 type Owned = PyStrRef ;
713- #[ inline]
713+ #[ inline( always ) ]
714714 fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
715715 self . to_owned ( )
716716 }
717-
717+ # [ inline ]
718718 fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
719719 Ok ( self . hash ( vm) )
720720 }
721-
721+ # [ inline ( always ) ]
722722 fn key_is ( & self , other : & PyObject ) -> bool {
723723 self . is ( other)
724724 }
@@ -732,28 +732,31 @@ impl DictKey for Py<PyStr> {
732732 vm. bool_eq ( self . as_object ( ) , other_key)
733733 }
734734 }
735-
735+ # [ inline ( always ) ]
736736 fn key_as_isize ( & self , vm : & VirtualMachine ) -> PyResult < isize > {
737737 self . as_object ( ) . key_as_isize ( vm)
738738 }
739739}
740740
741- impl DictKey for PyRefExact < PyStr > {
742- type Owned = Self ;
743- #[ inline]
741+ impl DictKey for PyExact < PyStr > {
742+ type Owned = PyRefExact < PyStr > ;
743+ #[ inline( always ) ]
744744 fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
745- self . clone ( )
745+ self . to_owned ( )
746746 }
747-
747+ # [ inline ( always ) ]
748748 fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
749749 ( * * self ) . key_hash ( vm)
750750 }
751+ #[ inline]
751752 fn key_is ( & self , other : & PyObject ) -> bool {
752753 ( * * self ) . key_is ( other)
753754 }
755+ #[ inline( always) ]
754756 fn key_eq ( & self , vm : & VirtualMachine , other_key : & PyObject ) -> PyResult < bool > {
755757 ( * * self ) . key_eq ( vm, other_key)
756758 }
759+ #[ inline( always) ]
757760 fn key_as_isize ( & self , vm : & VirtualMachine ) -> PyResult < isize > {
758761 ( * * self ) . key_as_isize ( vm)
759762 }
@@ -765,16 +768,16 @@ impl DictKey for PyRefExact<PyStr> {
765768/// to index dictionaries.
766769impl DictKey for str {
767770 type Owned = String ;
768- #[ inline]
771+ #[ inline( always ) ]
769772 fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
770773 self . to_owned ( )
771774 }
772-
775+ # [ inline ]
773776 fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
774777 // follow a similar route as the hashing of PyStrRef
775778 Ok ( vm. state . hash_secret . hash_str ( self ) )
776779 }
777-
780+ # [ inline ( always ) ]
778781 fn key_is ( & self , _other : & PyObject ) -> bool {
779782 // No matter who the other pyobject is, we are never the same thing, since
780783 // we are a str, not a pyobject.
0 commit comments