From 25cd1c0b60604655b70d70f8ec33a54853905eea Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 18 Mar 2026 16:28:46 -1030 Subject: optimize pathfinder swarms and write perf guide --- azalea-buf/src/impls/extra.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'azalea-buf/src/impls') 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); impl_for_list_type!(Box<[T]>); +// `Arc<[T]>` is deliberately not implemented here, because converting a +// `Vec` 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>`. impl AzBuf for Vec { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { -- cgit v1.2.3