[polari/gnome-3-36] roomStack: Cache entry-area-height to avoid notifying unconditionally



commit d5544df1b262c183454fa6789a0cf4406c86a65f
Author: Philip Withnall <withnall endlessm com>
Date:   Wed May 6 17:03:21 2020 +0100

    roomStack: Cache entry-area-height to avoid notifying unconditionally
    
    If the code notifies of changes to entry-area-height unconditionally (i.e.
    even if the actual value of entry-area-height hasn’t changed), it can lead
    to a lot of unnecessary resize cycles.
    
    Avoid that by storing the old value and only emitting a notification if
    it’s changed.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://gitlab.gnome.org/GNOME/polari/-/merge_requests/157

 src/roomStack.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/roomStack.js b/src/roomStack.js
index 3f97ed6a..0a7232fc 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -34,8 +34,10 @@ var RoomStack = GObject.registerClass({
 
         this._entryAreaHeight = 0;
         this._sizeGroup.get_widgets()[0].connect('size-allocate', (w, rect) => {
-            this._entryAreaHeight = rect.height - 1;
-            this.notify('entry-area-height');
+            if (this._entryAreaHeight !== rect.height - 1) {
+                this._entryAreaHeight = rect.height - 1;
+                this.notify('entry-area-height');
+            }
         });
 
         this.connect('destroy', () => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]