From 95ec1276ca82f65cfcb298fb20b1a8ab39ed44ce Mon Sep 17 00:00:00 2001 From: Ritchie Vink Date: Mon, 16 Jan 2023 23:03:42 +0100 Subject: [PATCH] Added set/get scratches (#1363) --- src/io/ipc/read/reader.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/io/ipc/read/reader.rs b/src/io/ipc/read/reader.rs index da584fadeed..4114f79e615 100644 --- a/src/io/ipc/read/reader.rs +++ b/src/io/ipc/read/reader.rs @@ -71,6 +71,21 @@ impl FileReader { self.reader } + /// Get the inner memory scratches so they can be reused in a new writer. + /// This can be utilized to save memory allocations for performance reasons. + pub fn get_scratches(&mut self) -> (Vec, Vec) { + ( + std::mem::take(&mut self.data_scratch), + std::mem::take(&mut self.message_scratch), + ) + } + + /// Set the inner memory scratches so they can be reused in a new writer. + /// This can be utilized to save memory allocations for performance reasons. + pub fn set_scratches(&mut self, scratches: (Vec, Vec)) { + (self.data_scratch, self.message_scratch) = scratches; + } + fn read_dictionaries(&mut self) -> Result<()> { if self.dictionaries.is_none() { self.dictionaries = Some(read_file_dictionaries(