|
1 | | -use std::mem; |
2 | | -use std::mem::MaybeUninit; |
3 | | - |
4 | 1 | use vortex_array::compute::{ |
5 | 2 | BetweenFn, BetweenOptions, FilterKernelAdapter, KernelRef, ScalarAtFn, SearchSortedFn, SliceFn, |
6 | 3 | TakeFn, between, |
@@ -48,37 +45,28 @@ fn chunked_indices<F: FnMut(usize, &[usize])>( |
48 | 45 | offset: usize, |
49 | 46 | mut chunk_fn: F, |
50 | 47 | ) { |
51 | | - let mut indices_within_chunk = [const { MaybeUninit::<usize>::uninit() }; 1024]; |
52 | | - let mut indices_len = 0; |
| 48 | + let mut indices_within_chunk: Vec<usize> = Vec::with_capacity(1024); |
53 | 49 |
|
54 | 50 | let Some(first_idx) = indices.next() else { |
55 | 51 | return; |
56 | 52 | }; |
57 | 53 |
|
58 | 54 | let mut current_chunk_idx = (first_idx + offset) / 1024; |
59 | | - indices_within_chunk[indices_len] = MaybeUninit::new((first_idx + offset) % 1024); |
60 | | - indices_len += 1; |
| 55 | + indices_within_chunk.push((first_idx + offset) % 1024); |
61 | 56 | for idx in indices { |
62 | 57 | let new_chunk_idx = (idx + offset) / 1024; |
63 | 58 |
|
64 | 59 | if new_chunk_idx != current_chunk_idx { |
65 | | - chunk_fn(current_chunk_idx, unsafe { |
66 | | - mem::transmute::<&[MaybeUninit<usize>], &[usize]>( |
67 | | - &indices_within_chunk[..indices_len], |
68 | | - ) |
69 | | - }); |
70 | | - indices_len = 0; |
| 60 | + chunk_fn(current_chunk_idx, &indices_within_chunk); |
| 61 | + indices_within_chunk.clear(); |
71 | 62 | } |
72 | 63 |
|
73 | 64 | current_chunk_idx = new_chunk_idx; |
74 | | - indices_within_chunk[indices_len] = MaybeUninit::new((idx + offset) % 1024); |
75 | | - indices_len += 1; |
| 65 | + indices_within_chunk.push((idx + offset) % 1024); |
76 | 66 | } |
77 | 67 |
|
78 | | - if indices_len > 0 { |
79 | | - chunk_fn(current_chunk_idx, unsafe { |
80 | | - mem::transmute::<&[MaybeUninit<usize>], &[usize]>(&indices_within_chunk[..indices_len]) |
81 | | - }); |
| 68 | + if !indices_within_chunk.is_empty() { |
| 69 | + chunk_fn(current_chunk_idx, &indices_within_chunk); |
82 | 70 | } |
83 | 71 | } |
84 | 72 |
|
|
0 commit comments