From f8130c3c92946d2293634ba4e252d6bc93026c3c Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 23 Feb 2025 03:10:21 +0000 Subject: minor memory usage optimizations --- azalea-buf/src/read.rs | 7 +++++++ azalea-buf/src/write.rs | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'azalea-buf/src') diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index e6f7aa51..324eab87 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -3,6 +3,7 @@ use std::{ collections::HashMap, hash::Hash, io::{Cursor, Read}, + sync::Arc, }; use byteorder::{BE, ReadBytesExt}; @@ -423,3 +424,9 @@ impl AzaleaRead for (A, B) { Ok((A::azalea_read(buf)?, B::azalea_read(buf)?)) } } + +impl AzaleaRead for Arc { + fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { + Ok(Arc::new(T::azalea_read(buf)?)) + } +} diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs index c4b9f413..73aefe40 100755 --- a/azalea-buf/src/write.rs +++ b/azalea-buf/src/write.rs @@ -1,6 +1,7 @@ use std::{ collections::HashMap, io::{self, Write}, + sync::Arc, }; use byteorder::{BigEndian, WriteBytesExt}; @@ -298,3 +299,9 @@ impl AzaleaWrite for (A, B) { self.1.azalea_write(buf) } } + +impl AzaleaWrite for Arc { + fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> { + T::azalea_write(&**self, buf) + } +} -- cgit v1.2.3