@@ -225,16 +225,14 @@ fn general_list_repeat<O: OffsetSizeTrait>(
225225 let mut inner_total = 0usize ;
226226 for i in 0 ..count_array. len ( ) {
227227 let count = get_count_with_validity ( count_array, i) ;
228- if count > 0 {
229- if list_array. is_valid ( i) {
230- let len = list_offsets[ i + 1 ] . to_usize ( ) . unwrap ( )
231- - list_offsets[ i] . to_usize ( ) . unwrap ( ) ;
232- inner_total = checked_repeat_len_add (
233- inner_total,
234- checked_repeat_len_mul ( len, count) ?,
235- ) ?;
236- ensure_array_repeat_output_len :: < O > ( inner_total) ?;
237- }
228+ if count > 0 && list_array. is_valid ( i) {
229+ let len = list_offsets[ i + 1 ] . to_usize ( ) . unwrap ( )
230+ - list_offsets[ i] . to_usize ( ) . unwrap ( ) ;
231+ inner_total = checked_repeat_len_add (
232+ inner_total,
233+ checked_repeat_len_mul ( len, count) ?,
234+ ) ?;
235+ ensure_array_repeat_output_len :: < O > ( inner_total) ?;
238236 }
239237 }
240238
@@ -362,11 +360,9 @@ fn max_offset_elements<O: OffsetSizeTrait>() -> usize {
362360
363361fn max_vec_elements < T > ( ) -> usize {
364362 let element_size = size_of :: < T > ( ) ;
365- if element_size == 0 {
366- usize:: MAX
367- } else {
368- isize:: MAX as usize / element_size
369- }
363+ ( isize:: MAX as usize )
364+ . checked_div ( element_size)
365+ . unwrap_or ( usize:: MAX )
370366}
371367
372368/// Helper function to get count from count_array at given index
0 commit comments