Skip to content

Commit 8807026

Browse files
committed
use unsafe to get in Vec.
1 parent e3ba95c commit 8807026

File tree

1 file changed

+6
-5
lines changed
  • datafusion/physical-plan/src/aggregates/group_values/single_group_by

1 file changed

+6
-5
lines changed

datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,15 @@ where
366366
let block_id = O::get_block_id(*g);
367367
let block_offset = O::get_block_offset(*g);
368368
self.values
369-
.get(block_id as usize)
370-
.unwrap()
369+
.get_unchecked(block_id as usize)
371370
.get_unchecked(block_offset as usize)
372371
.is_eq(key)
373372
},
374373
|g| unsafe {
375374
let block_id = O::get_block_id(*g);
376375
let block_offset = O::get_block_offset(*g);
377376
self.values
378-
.get(block_id as usize)
379-
.unwrap()
377+
.get_unchecked(block_id as usize)
380378
.get_unchecked(block_offset as usize)
381379
.hash(state)
382380
},
@@ -391,7 +389,10 @@ where
391389
// Get block infos and update block,
392390
// we need `current block` and `next offset in block`
393391
let block_id = self.values.len() as u32 - 1;
394-
let current_block = self.values.last_mut().unwrap();
392+
let current_block = unsafe {
393+
let last_index = self.values.len() - 1;
394+
self.values.get_unchecked_mut(last_index)
395+
};
395396
let block_offset = current_block.len() as u64;
396397
current_block.push(key);
397398

0 commit comments

Comments
 (0)