163163
164164use std:: any:: type_name;
165165use std:: cell:: UnsafeCell ;
166- use std:: collections:: hash_map:: { Entry , HashMap } ;
166+ use std:: collections:: hash_map:: Entry ;
167167use std:: fmt;
168168use std:: mem:: size_of;
169169use std:: ops:: Deref ;
170170
171+ use ahash:: AHashMap ;
171172use ndarray:: { ArrayView , ArrayViewMut , Dimension , Ix1 , Ix2 , Ix3 , Ix4 , Ix5 , Ix6 , IxDyn } ;
172173use num_integer:: gcd;
173174use pyo3:: { FromPyObject , PyAny , PyResult } ;
@@ -235,7 +236,7 @@ impl BorrowKey {
235236 }
236237}
237238
238- type BorrowFlagsInner = HashMap < usize , HashMap < BorrowKey , isize > > ;
239+ type BorrowFlagsInner = AHashMap < usize , AHashMap < BorrowKey , isize > > ;
239240
240241struct BorrowFlags ( UnsafeCell < Option < BorrowFlagsInner > > ) ;
241242
@@ -248,7 +249,7 @@ impl BorrowFlags {
248249
249250 #[ allow( clippy:: mut_from_ref) ]
250251 unsafe fn get ( & self ) -> & mut BorrowFlagsInner {
251- ( * self . 0 . get ( ) ) . get_or_insert_with ( HashMap :: new)
252+ ( * self . 0 . get ( ) ) . get_or_insert_with ( AHashMap :: new)
252253 }
253254
254255 fn acquire < T , D > ( & self , array : & PyArray < T , D > ) -> Result < ( ) , BorrowError >
@@ -292,7 +293,7 @@ impl BorrowFlags {
292293 }
293294 }
294295 Entry :: Vacant ( entry) => {
295- let mut same_base_arrays = HashMap :: with_capacity ( 1 ) ;
296+ let mut same_base_arrays = AHashMap :: with_capacity ( 1 ) ;
296297 same_base_arrays. insert ( key, 1 ) ;
297298 entry. insert ( same_base_arrays) ;
298299 }
@@ -363,7 +364,7 @@ impl BorrowFlags {
363364 }
364365 }
365366 Entry :: Vacant ( entry) => {
366- let mut same_base_arrays = HashMap :: with_capacity ( 1 ) ;
367+ let mut same_base_arrays = AHashMap :: with_capacity ( 1 ) ;
367368 same_base_arrays. insert ( key, -1 ) ;
368369 entry. insert ( same_base_arrays) ;
369370 }
0 commit comments