[PR #3083] [MERGED] HUD paint: build the sprite key in one reused buffer #4791

Closed
opened 2026-11-03 05:07:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3083
Author: @Domanffe
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: perf/hud-paint-reuses-sprite-key


📝 Commits (1)

  • 4bf633e HUD paint: build the sprite key in one reused buffer

📊 Changes

1 file changed (+9 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/hud_layout.rs (+9 -5)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

hud_layout::paint runs once per frame over every GuiDraw the HUD produced
and built a fresh String per sprite just to look it up in the atlas:
sprite.to_string() for a mob_effect/ blit and format!("gui/sprites/{sprite}")
for the rest. A frame that draws the health bar, armour, air and food makes one
of those for every icon.

The key is now assembled in one String outside the loop and cleared per
draw. The keys themselves are unchanged, so the atlas hits are the same; the
only difference is no allocation per sprite.

CARGO_TARGET_DIR=E:/Projects/horizon-target cargo check -p horizon-client --all-targets → Finished dev profile ... in 1m 36s, no warnings from this
change. No benchmark scene isolates paint, so I am not claiming a number: the
change stands on the allocation it removes per drawn sprite per frame.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3083 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/hud-paint-reuses-sprite-key` --- ### 📝 Commits (1) - [`4bf633e`](https://github.com/horizon-rust/horizon/commit/4bf633e8a9cb17aa94ac17d1010613f0b3bcdf98) HUD paint: build the sprite key in one reused buffer ### 📊 Changes **1 file changed** (+9 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/hud_layout.rs` (+9 -5) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. `hud_layout::paint` runs once per frame over every `GuiDraw` the HUD produced and built a fresh `String` per sprite just to look it up in the atlas: `sprite.to_string()` for a `mob_effect/` blit and `format!("gui/sprites/{sprite}")` for the rest. A frame that draws the health bar, armour, air and food makes one of those for every icon. The key is now assembled in one `String` outside the loop and cleared per draw. The keys themselves are unchanged, so the atlas hits are the same; the only difference is no allocation per sprite. `CARGO_TARGET_DIR=E:/Projects/horizon-target cargo check -p horizon-client --all-targets` → `Finished dev profile ... in 1m 36s`, no warnings from this change. No benchmark scene isolates `paint`, so I am not claiming a number: the change stands on the allocation it removes per drawn sprite per frame. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4791
No description provided.