File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -100,14 +100,16 @@ const CAPACITY: usize = 65536;
100100
101101#[ derive( Debug ) ]
102102struct PyStringCache {
103- entries : Vec < Option < ( u64 , Py < PyString > ) > > ,
103+ entries : [ Option < ( u64 , Py < PyString > ) > ; CAPACITY ] ,
104104 hash_builder : BuildHasherDefault < AHasher > ,
105105}
106106
107+ const ARRAY_REPEAT_VALUE : Option < ( u64 , Py < PyString > ) > = None ;
108+
107109impl Default for PyStringCache {
108110 fn default ( ) -> Self {
109111 Self {
110- entries : vec ! [ None ; CAPACITY ] ,
112+ entries : [ ARRAY_REPEAT_VALUE ; CAPACITY ] ,
111113 hash_builder : BuildHasherDefault :: default ( ) ,
112114 }
113115 }
@@ -159,7 +161,6 @@ impl PyStringCache {
159161
160162 /// clear the cache by resetting all entries to `None`
161163 fn clear ( & mut self ) {
162- self . entries . clear ( ) ;
163- self . entries . resize ( CAPACITY , None ) ;
164+ self . entries = [ ARRAY_REPEAT_VALUE ; CAPACITY ] ;
164165 }
165166}
You can’t perform that action at this time.
0 commit comments