File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,13 @@ impl SketchHashMap {
124124 }
125125 }
126126
127+ fn with_capacity ( capacity : usize ) -> SketchHashMap {
128+ SketchHashMap {
129+ map : HashMap :: with_capacity ( capacity) ,
130+ head : SketchHashKey :: Invalid ,
131+ }
132+ }
133+
127134 /// Increment the count at a key, creating the entry if needed.
128135 fn increment ( & mut self , key : SketchHashKey ) {
129136 self . entry_upsert ( key, 1 ) ;
@@ -273,7 +280,7 @@ impl UDDSketch {
273280 counts : impl Iterator < Item = u64 > ,
274281 ) -> Self {
275282 let mut sketch = UDDSketch {
276- buckets : SketchHashMap :: new ( ) ,
283+ buckets : SketchHashMap :: with_capacity ( metadata . values as usize ) ,
277284 alpha : metadata. current_error ,
278285 gamma : gamma ( metadata. current_error ) ,
279286 compactions : metadata. compactions ,
You can’t perform that action at this time.
0 commit comments