Tooltips: compare the hidden component id without a UTF-16 copy

TooltipDisplay.shows built a JavaString from the id on every call just to
test membership in the NBT list. A hovered tooltip asks this a dozen times
per frame, so the hover allocated a dozen short vectors per frame for a read.

Co-Authored-By: Hermes Agent (Nous Research) <noreply@nousresearch.com>
This commit is contained in:
Alexander Krylov
2026-10-26 09:55:58 +03:00
parent 5bcc87983e
commit 73bbbd3ee8
+3 -4
View File
@@ -56,10 +56,9 @@ impl<'a> TooltipDisplay<'a> {
else {
return true;
};
let component = horizon_world::nbt::JavaString::from(component);
!hidden
.iter()
.any(|tag| matches!(tag, Tag::String(id) if id == &component))
!hidden.iter().any(|tag| {
matches!(tag, Tag::String(id) if id.0.iter().copied().eq(component.encode_utf16()))
})
}
}