From 0e30223564e272b698250e41255e188e0a7d1430 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 9 Jan 2026 16:17:55 -0500 Subject: [PATCH 1/2] perf: Avoid allocation in PrimitiveArray::reinterpret_cast --- arrow-array/src/array/primitive_array.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arrow-array/src/array/primitive_array.rs b/arrow-array/src/array/primitive_array.rs index 457c2428145e..cde490a3ab18 100644 --- a/arrow-array/src/array/primitive_array.rs +++ b/arrow-array/src/array/primitive_array.rs @@ -859,11 +859,9 @@ impl PrimitiveArray { where K: ArrowPrimitiveType, { - let d = self.to_data().into_builder().data_type(K::DATA_TYPE); - // SAFETY: // Native type is the same - PrimitiveArray::from(unsafe { d.build_unchecked() }) + PrimitiveArray::new(self.values.clone(), self.nulls.clone()) } /// Applies a unary infallible function to a primitive array, producing a From 0dcbcd67b54c0142e8a2f85037a0ede65cd6f293 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 9 Jan 2026 16:24:20 -0500 Subject: [PATCH 2/2] stale commens --- arrow-array/src/array/primitive_array.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/arrow-array/src/array/primitive_array.rs b/arrow-array/src/array/primitive_array.rs index cde490a3ab18..87de5f61605f 100644 --- a/arrow-array/src/array/primitive_array.rs +++ b/arrow-array/src/array/primitive_array.rs @@ -859,8 +859,6 @@ impl PrimitiveArray { where K: ArrowPrimitiveType, { - // SAFETY: - // Native type is the same PrimitiveArray::new(self.values.clone(), self.nulls.clone()) }