Skip to content

Navigation Menu

Sign in
Sign up

perf(messages): fold ASCII highlight segments once - #178

Open
YousefHadder wants to merge 1 commit into
gammons:main from
YousefHadder:yousefhadder/messages-fold-ascii-segments
Open

perf(messages): fold ASCII highlight segments once #178
YousefHadder wants to merge 1 commit into
gammons:main from
YousefHadder:yousefhadder/messages-fold-ascii-segments

Conversation

@YousefHadder

@YousefHadder YousefHadder commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the private hand-rolled ASCII lowering path with segment-level internal/text.Fold now that PR perf(text): add ASCII fast path to Fold #174 centralizes the ASCII fast path.
  • Fold valid ASCII segments once, then split the result back into the existing one-entry-per-rune mapping.
  • Keep the per-rune text.Fold fallback for non-ASCII and invalid UTF-8 so highlight indices and behavior remain unchanged.

Behavior coverage

Behavior-level tests exercise the HighlightSearchTerms package seam, including decomposed combining-mark mapping (Cafe\u0301) to preserve the original rune-to-highlight relationship.

Observed benchmark

Environment: Apple M3 Max, darwin/arm64.

Protocol:

go test ./internal/ui/messages -run '^$' -bench '^BenchmarkHighlightSearchTerms_ASCII$' -benchmem -count=6 -benchtime=500ms
Implementation Median ns/op Observed range ns/op B/op allocs/op
Original hand-rolled baseline 2,789 2,755-3,318 5,008 185
Final coarse text.Fold path 1,855 1,837-1,921 4,304 9

In these measurements, the median was 33.5% lower and allocations decreased from 185 to 9 per operation. These are observed results on the environment above, not universal performance claims.

Context

This is the independent message-highlighting follow-up requested after PR #174 / issue #165. It is separate from the reaction-picker follow-up in PR #177.

Refs #165

Copy link
Copy Markdown

Great

YousefHadder reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /