scovich commented on PR #7987: URL: https://github.com/apache/arrow-rs/pull/7987#issuecomment-3122190114
> I meant avoiding that allocation by shifting the byes over in one go and then writing directly into the output buffer: > > ```rust > // insert header_size bytes into the output, shifting existing bytes down > buffer.splice(starting_offset..starting_offset+header_length, std::iter::repeat(0)); > // write header directly into buffer[starting_offset], buffer[starting_offset+1], etc > ``` Yeah, IIRC that was the original approach, but I had cautioned that calculating the splice size incorrectly would cause subsequent indexing to corrupt the variant (either by leaving unused zeros or by overflowing the spliced region). And since the original approach was anyway using `vec![0u8; header_length]` as the source of zeros, I suggested to populate the vec directly instead. Safe and not more expensive. It could be that not allocating the temp buffer at all does improve performance even further, tho it would come with the risk of corruption if the spliced region were ever the wrong size. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org