Perf: single-raise timing notifications + cheaper ASSA event-line parsing#12073
Merged
Conversation
…g changes TextBackgroundBrush depends only on Text, but was raised from OnEndTimeChanged, OnDurationChanged and UpdateDuration - its getter strips HTML and shapes the text with HarfBuzz, and waveform drags assign times at pointer-move rate, so realized rows re-shaped text several times per mouse event. OnEndTimeChanged also duplicated all of UpdateDuration's raises, doubling every notification per EndTime assignment. OnGapChanged raised DurationBackgroundBrush, which does not read Gap. Make UpdateDuration the single raise site for the timing-derived properties and add CpsBackgroundBrush/WpmBackgroundBrush there, so start-time drags now repaint them too (previously only end-time changes did). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…title Every event line was copied via ToLowerInvariant just for a few prefix checks - use case-insensitive StartsWith instead and lowercase only the short format field list. The text field rejoin used repeated string concatenation per comma; use a pooled StringBuilder. Also reuse the already-trimmed line instead of three extra TrimStart calls. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two hot-path fixes from the second performance review round.
Subtitle line timing notifications (grid / waveform drags)
TextBackgroundBrushwas raised fromOnEndTimeChanged,OnDurationChanged, andUpdateDuration, but its getter depends only onText(line length / pixel width / line count) — and it strips HTML and shapes text with HarfBuzz per evaluation. Waveform drags assignStartTime/EndTimeper pointer move (60–120 Hz), so realized rows re-shaped their text up to ~3× per mouse event for no reason.OnEndTimeChangedfirst calledUpdateDuration(which raises CPS/WPM/brushes) and then raised the same set again — every end-time assignment notified twice.OnGapChangedraisedDurationBackgroundBrush, which doesn't readGap.UpdateDurationis now the single raise site for timing-derived properties (all timing mutations —OnStartTimeChanged,OnEndTimeChanged,SetTimes,SetStartTimeOnly— funnel through it). It also gainsCpsBackgroundBrush/WpmBackgroundBrush, fixing a latent staleness bug: dragging the start edge changed CPS but never repainted the CPS/WPM cell backgrounds.TextBackgroundBrushkeeps its two correct raise sites:OnTextChangedand the settings-dependent refresh.ASSA
LoadSubtitleToLowerInvariant()just for a handful of prefix checks (format:,dialogue:,comment:) — for a 100k-line .ass that's 100k full-line lowercase copies, doubled by theIsMinepre-parse. Now usesStartsWith(..., OrdinalIgnoreCase); only the short format field list is lowercased.text += "," + partper comma in the dialogue text) is now a pooledStringBuilder.trimmedLineinstead of three extraTrimStart()calls per line.All 997 tests pass (libse 485, UI 512).
🤖 Generated with Claude Code