diff options
| author | mat <git@matdoes.dev> | 2025-02-23 03:10:21 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-23 03:10:21 +0000 |
| commit | f8130c3c92946d2293634ba4e252d6bc93026c3c (patch) | |
| tree | 08fc6097137d7b4d31b692f4ba993b23acc64eb7 /azalea-buf/src | |
| parent | 34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (diff) | |
| download | azalea-drasl-f8130c3c92946d2293634ba4e252d6bc93026c3c.tar.xz | |
minor memory usage optimizations
Diffstat (limited to 'azalea-buf/src')
| -rwxr-xr-x | azalea-buf/src/read.rs | 7 | ||||
| -rwxr-xr-x | azalea-buf/src/write.rs | 7 |
2 files changed, 14 insertions, 0 deletions
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<A: AzaleaRead, B: AzaleaRead> AzaleaRead for (A, B) { Ok((A::azalea_read(buf)?, B::azalea_read(buf)?)) } } + +impl<T: AzaleaRead> AzaleaRead for Arc<T> { + fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + 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<A: AzaleaWrite, B: AzaleaWrite> AzaleaWrite for (A, B) { self.1.azalea_write(buf) } } + +impl<T: AzaleaWrite> AzaleaWrite for Arc<T> { + fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> { + T::azalea_write(&**self, buf) + } +} |
