diff options
| author | mat <git@matdoes.dev> | 2026-03-18 16:28:46 -1030 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-20 04:21:58 -0200 |
| commit | 25cd1c0b60604655b70d70f8ec33a54853905eea (patch) | |
| tree | 28911045f6d69b2fffcb8d9c5a92fe32657b5e4b /azalea-buf/src | |
| parent | b03d2942e1bef98e13acadde5cbb8856a3f8c74d (diff) | |
| download | azalea-drasl-25cd1c0b60604655b70d70f8ec33a54853905eea.tar.xz | |
optimize pathfinder swarms and write perf guide
Diffstat (limited to 'azalea-buf/src')
| -rw-r--r-- | azalea-buf/src/impls/extra.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/azalea-buf/src/impls/extra.rs b/azalea-buf/src/impls/extra.rs index f22ddb1a..8312e8fb 100644 --- a/azalea-buf/src/impls/extra.rs +++ b/azalea-buf/src/impls/extra.rs @@ -84,7 +84,7 @@ macro_rules! impl_for_list_type { } default fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { (self.len() as u32).azalea_write_var(buf)?; - for item in self { + for item in self.iter() { T::azalea_write(item, buf)?; } Ok(()) @@ -101,7 +101,7 @@ macro_rules! impl_for_list_type { } fn azalea_write_var(&self, buf: &mut impl Write) -> io::Result<()> { (self.len() as u32).azalea_write_var(buf)?; - for item in self { + for item in self.iter() { T::azalea_write_var(item, buf)?; } Ok(()) @@ -132,6 +132,10 @@ macro_rules! impl_for_list_type { impl_for_list_type!(Vec<T>); impl_for_list_type!(Box<[T]>); +// `Arc<[T]>` is deliberately not implemented here, because converting a +// `Vec<T>` to `Arc<[T]>` results in allocations (since `Arc` stores the +// counters on the heap) and we'd like to avoid that. for us it's typically +// better to do `Arc<Box<[T]>>`. impl AzBuf for Vec<u8> { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { |
