From ee2575794e91b9457a74a95daf1dcc707058cd58 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 12 Oct 2025 23:01:54 +0300 Subject: upgrade deps and clean up lots of doc comments --- azalea-chat/src/translatable_component.rs | 98 ++++--------------------------- 1 file changed, 10 insertions(+), 88 deletions(-) (limited to 'azalea-chat/src/translatable_component.rs') diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs index 13afe6b7..ae1d80bc 100644 --- a/azalea-chat/src/translatable_component.rs +++ b/azalea-chat/src/translatable_component.rs @@ -2,7 +2,10 @@ use std::fmt::{self, Display}; use serde::{Deserialize, Serialize}; #[cfg(feature = "simdnbt")] -use simdnbt::ToNbtTag; +use simdnbt::{ + ToNbtTag, + owned::{NbtList, NbtTag}, +}; use crate::{FormattedText, base_component::BaseComponent, text_component::TextComponent}; @@ -49,93 +52,12 @@ pub struct TranslatableComponent { } #[cfg(feature = "simdnbt")] -fn serialize_args_as_nbt(args: Vec) -> simdnbt::owned::NbtList { - let tags: Vec = args.into_iter().map(|arg| arg.to_nbt_tag()).collect(); - - if let Some(first_element) = tags.first() { - let tags = tags.clone(); - let homogenous_list = match first_element { - simdnbt::owned::NbtTag::Byte(_) => tags - .into_iter() - .map(|tag| tag.into_byte()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Short(_) => tags - .into_iter() - .map(|tag| tag.into_short()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Int(_) => tags - .into_iter() - .map(|tag| tag.into_int()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Long(_) => tags - .into_iter() - .map(|tag| tag.into_long()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Float(_) => tags - .into_iter() - .map(|tag| tag.into_float()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Double(_) => tags - .into_iter() - .map(|tag| tag.into_double()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::ByteArray(_) => tags - .into_iter() - .map(|tag| tag.into_byte_array()) - .collect::>>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::String(_) => tags - .into_iter() - .map(|tag| tag.into_string()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::List(_) => tags - .into_iter() - .map(|tag| tag.into_list()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::Compound(_) => tags - .into_iter() - .map(|tag| tag.into_compound()) - .collect::>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::IntArray(_) => tags - .into_iter() - .map(|tag| tag.into_int_array()) - .collect::>>>() - .map(simdnbt::owned::NbtList::from), - simdnbt::owned::NbtTag::LongArray(_) => tags - .into_iter() - .map(|tag| tag.into_long_array()) - .collect::>>>() - .map(simdnbt::owned::NbtList::from), - }; - - if let Some(homogenous_list) = homogenous_list { - return homogenous_list; - } - } - - let mut compounds = Vec::with_capacity(tags.len()); - for tag in tags { - let compound = if let simdnbt::owned::NbtTag::Compound(compound) = tag { - compound - } else { - let mut compound = simdnbt::owned::NbtCompound::new(); - compound.insert("", tag); - compound - }; - - compounds.push(compound); - } - - compounds.into() +fn serialize_args_as_nbt(args: Vec) -> NbtList { + let tags = args + .into_iter() + .map(|arg| arg.to_nbt_tag()) + .collect::>(); + NbtList::from(tags) } #[cfg(feature = "simdnbt")] -- cgit v1.2.3