Use case: I frequently need to toggle the visibility of several views based on certain conditions. This results in many calls to SetDisplay() with the same value during a single frame.
I noticed that many Set* methods (SetDisplay, SetWidth, SetHeight, etc.) trigger Layout() unconditionally, even when the new value equals the current one. Not sure if this causes any significant performance degradation, but it's clearly wasteful.
|
// SetDisplay sets the display property of the view. |
|
func (v *View) SetDisplay(display Display) { |
|
v.Display = display |
|
v.Layout() |
|
} |
Proposed fix: add an early return if unchanged:
func (v *View) SetDisplay(display Display) {
if v.Display == display { return }
v.Display = display
v.Layout()
}
Would a PR covering all relevant Set* methods be welcome?
Use case: I frequently need to toggle the visibility of several views based on certain conditions. This results in many calls to
SetDisplay()with the same value during a single frame.I noticed that many
Set*methods (SetDisplay,SetWidth,SetHeight, etc.) triggerLayout()unconditionally, even when the new value equals the current one. Not sure if this causes any significant performance degradation, but it's clearly wasteful.furex-ui/view.go
Lines 377 to 381 in 0995989
Proposed fix: add an early return if unchanged:
Would a PR covering all relevant
Set*methods be welcome?