[PR #2027] [MERGED] Signs: cut the first line on byte offsets, not through a char copy #3954

Closed
opened 2026-11-03 04:13:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/sign-first-line


📝 Commits (2)

  • 1e9644c Signs: cut the first line on byte offsets, not through a char copy
  • 81e4272 Merge remote-tracking branch 'origin/main' into perf/sign-first-line

📊 Changes

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

View changed files

📝 crates/horizon-client/src/block_entity_render.rs (+15 -5)

📄 Description

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

first_line (the StringSplitter.splitLines(..).get(0) port behind sign text) collected the whole line into a Vec<char> and then re-collected a prefix of that vector into a String. A sign costs that twice per line, front and back, on every frame, and none of the cut points it needs require counting chars: they are byte offsets into the input.

The loop now walks line.char_indices(). The wide-first-char case still keeps that one char (c.len_utf8()), which is what the old i.max(1) produced.

The new test pins the behaviour the port has to keep: wrap at the last space that fits, mid-word when there is none, a multibyte first char that is wider than the limit on its own, and the newline cut.

The pr_ready --quick block follows as a comment.


🔄 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/2027 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/sign-first-line` --- ### 📝 Commits (2) - [`1e9644c`](https://github.com/horizon-rust/horizon/commit/1e9644cc1577d2382965fa8733f2190e2cebad58) Signs: cut the first line on byte offsets, not through a char copy - [`81e4272`](https://github.com/horizon-rust/horizon/commit/81e4272126f40c8a7a12aad00a5efaa0cc723095) Merge remote-tracking branch 'origin/main' into perf/sign-first-line ### 📊 Changes **1 file changed** (+15 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_render.rs` (+15 -5) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. `first_line` (the `StringSplitter.splitLines(..).get(0)` port behind sign text) collected the whole line into a `Vec<char>` and then re-collected a prefix of that vector into a `String`. A sign costs that twice per line, front and back, on every frame, and none of the cut points it needs require counting chars: they are byte offsets into the input. The loop now walks `line.char_indices()`. The wide-first-char case still keeps that one char (`c.len_utf8()`), which is what the old `i.max(1)` produced. The new test pins the behaviour the port has to keep: wrap at the last space that fits, mid-word when there is none, a multibyte first char that is wider than the limit on its own, and the newline cut. The `pr_ready --quick` block follows as a comment. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:33 +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#3954
No description provided.