[PR #3086] [MERGED] Inventory draw: a slot is drawn from a reference, not a copy #4794

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

📋 Pull Request Information

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

Base: main ← Head: perf/draw-slot-item-by-reference


📝 Commits (2)

  • 626068d Inventory draw: a slot is drawn from a reference, not a copy
  • 3511d55 rustfmt

📊 Changes

3 files changed (+13 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+11 -11)
📝 crates/horizon-client/src/game/stations.rs (+1 -1)
📝 crates/horizon-client/src/game/trading.rs (+1 -1)

📄 Description

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

draw_slot_item took Option<ItemStack> by value and &mut self, so every
caller copied the stack into it: draw_inventory_slots, stations and
trading each built one copy per slot from slot_view, and the creative
hotbar built two (self.inventory[c].clone() plus stack.clone()).

The method reads the stack for draw_item_model and draw_item_decorations,
and reaches for self.carried only when a drag covers the slot, so it now
takes &Option<ItemStack> and &self. Callers pass a reference; the creative
hotbar clones a stack only when the pointer hovers it, for the tooltip.

CARGO_TARGET_DIR=E:/Projects/horizon-target cargo check -p horizon-client --all-targets → Finished dev profile ... in 3.87s. No benchmark scene
isolates the inventory screen, so I am not claiming a number: the change
stands on the copies it removes per drawn slot 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/3086 **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/draw-slot-item-by-reference` --- ### 📝 Commits (2) - [`626068d`](https://github.com/horizon-rust/horizon/commit/626068da3aec4bef2e45a5b1d19a89f010a8eb4a) Inventory draw: a slot is drawn from a reference, not a copy - [`3511d55`](https://github.com/horizon-rust/horizon/commit/3511d556ef7595e9748ca16a7d565654e1687d91) rustfmt ### 📊 Changes **3 files changed** (+13 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+11 -11) 📝 `crates/horizon-client/src/game/stations.rs` (+1 -1) 📝 `crates/horizon-client/src/game/trading.rs` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. `draw_slot_item` took `Option<ItemStack>` by value and `&mut self`, so every caller copied the stack into it: `draw_inventory_slots`, `stations` and `trading` each built one copy per slot from `slot_view`, and the creative hotbar built two (`self.inventory[c].clone()` plus `stack.clone()`). The method reads the stack for `draw_item_model` and `draw_item_decorations`, and reaches for `self.carried` only when a drag covers the slot, so it now takes `&Option<ItemStack>` and `&self`. Callers pass a reference; the creative hotbar clones a stack only when the pointer hovers it, for the tooltip. `CARGO_TARGET_DIR=E:/Projects/horizon-target cargo check -p horizon-client --all-targets` → `Finished dev profile ... in 3.87s`. No benchmark scene isolates the inventory screen, so I am not claiming a number: the change stands on the copies it removes per drawn slot 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:08:00 +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#4794
No description provided.