Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Added set/get scratches #1363

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/io/ipc/read/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ impl<R: Read + Seek> FileReader<R> {
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<u8>, Vec<u8>) {
(
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<u8>, Vec<u8>)) {
(self.data_scratch, self.message_scratch) = scratches;
}

fn read_dictionaries(&mut self) -> Result<()> {
if self.dictionaries.is_none() {
self.dictionaries = Some(read_file_dictionaries(
Expand Down