From 84c4508b399879349d1bd385c2b18d81a7be9964 Mon Sep 17 00:00:00 2001 From: Vegard Stikbakke Date: Mon, 27 Oct 2025 21:43:58 +0100 Subject: [PATCH] perf: Reduce allocations in cast_to_run_end_encoded --- arrow-cast/src/cast/run_array.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arrow-cast/src/cast/run_array.rs b/arrow-cast/src/cast/run_array.rs index 8d70afef3ab6..0d4679d9f3f5 100644 --- a/arrow-cast/src/cast/run_array.rs +++ b/arrow-cast/src/cast/run_array.rs @@ -136,8 +136,9 @@ pub(crate) fn cast_to_run_end_encoded( // Partition the array to identify runs of consecutive equal values let partitions = partition(&[Arc::clone(cast_array)])?; - let mut run_ends = Vec::new(); - let mut values_indexes = Vec::new(); + let size = partitions.len(); + let mut run_ends = Vec::with_capacity(size); + let mut values_indexes = Vec::with_capacity(size); let mut last_partition_end = 0; for partition in partitions.ranges() { values_indexes.push(last_partition_end);