[polari] roomStack: Cache entry-area-height to avoid notifying unconditionally



commit fc23229ecc14afab3ddd4255e966d99c086a2ff7
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 c821f35a..b18023ea 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]