Repository navigation
paint: eliminate redundant per-frame work in MultilinePreviewItemDelegate and FittedText - #77
Merged
Merged
Conversation
…gate and FittedText - MultilinePreviewItemDelegate.paint: bind parent view once instead of 6x, skip QRect.adjusted(0,0,0,0) when border_inset is 0, and pass the resolved (option, selected, row, wraps) tuple to _prepared_text so it does not re-call prepared_row() or view.wordWrap() on every painted row. - MultilinePreviewItemDelegate.eventFilter: read event.type() once and match against class frozenset DISCLOSURE_EVENTS instead of reading event.type() twice and rebuilding a set literal on every Qt event. - PreparedTextLayout.paint: call 2-arg QTextLayout.draw when no inks apply and avoid copying non-empty ink sequences per paint. - FittedText / ElidedLine / WrappedText: cache alignment int flags, WindowText palette color (invalidated on Palette/Style/Enabled/ApplicationPaletteChange), and width-keyed elided text (invalidated on setText and Font/Style/ApplicationFontChange), cutting repeated ElidedLine.paintEvent calls from 8 Python calls (with enum churn and re-elision) to 2.
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.
Cuts redundant per-frame Python and Qt calls profiled in Toad's
FrameWorkScenario:MultilinePreviewItemDelegate.paint/_prepared_text: reuseview,row,wrapsacross paint without duplicateprepared_row()/wordWrap()/parent()calls; skipQRect.adjusted(0,0,0,0)whenborder_inset == 0.MultilinePreviewItemDelegate.eventFilter: readevent.type()once and use class-levelfrozensetDISCLOSURE_EVENTSinstead of rebuilding a 4-item set literal on every event.PreparedTextLayout.paint: skiplist(...)copies and empty[]allocations when no inks apply.FittedText/ElidedLine/WrappedText: cache alignment flags,WindowTextpalette color, and width-keyed elided string (invalidated on text/font/palette/style/enabled/alignment changes), cutting steady-stateElidedLine.paintEventfrom 8 Python calls (with enum construction + re-elision) to 2.Tests:
test_list_preview_wrapping.py(27/27),test_fitted_text.py(2/2),test_virtual_rows_band.py(3/3) all pass.