[gnome-shell] workspacesView: Store some variables outside the children-allocate loop



commit 9152d6613b9fbcf56d1ae0cf727c8752c98e193a
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Tue Mar 9 18:12:02 2021 +0100

    workspacesView: Store some variables outside the children-allocate loop
    
    We've seen this to help quite a bit with performance previously, so also
    do it here.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1755>

 js/ui/workspacesView.js | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 757b5c3189..1af45d88d7 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -367,6 +367,11 @@ class WorkspacesView extends WorkspacesViewBase {
         if (rtl)
             workspaces.reverse();
 
+        const [fitSingleX1, fitSingleY1] = fitSingleBox.get_origin();
+        const [fitSingleWidth, fitSingleHeight] = fitSingleBox.get_size();
+        const [fitAllX1, fitAllY1] = fitAllBox.get_origin();
+        const [fitAllWidth, fitAllHeight] = fitAllBox.get_size();
+
         workspaces.forEach(child => {
             if (fitMode === FitMode.SINGLE)
                 box = fitSingleBox;
@@ -379,18 +384,18 @@ class WorkspacesView extends WorkspacesViewBase {
 
             if (vertical) {
                 fitSingleBox.set_origin(
-                    fitSingleBox.x1,
-                    fitSingleBox.y1 + fitSingleBox.get_height() + fitSingleSpacing);
+                    fitSingleX1,
+                    fitSingleBox.y1 + fitSingleHeight + fitSingleSpacing);
                 fitAllBox.set_origin(
-                    fitAllBox.x1,
-                    fitAllBox.y1 + fitAllBox.get_height() + fitAllSpacing);
+                    fitAllX1,
+                    fitAllBox.y1 + fitAllHeight + fitAllSpacing);
             } else {
                 fitSingleBox.set_origin(
-                    fitSingleBox.x1 + fitSingleBox.get_width() + fitSingleSpacing,
-                    fitSingleBox.y1);
+                    fitSingleBox.x1 + fitSingleWidth + fitSingleSpacing,
+                    fitSingleY1);
                 fitAllBox.set_origin(
-                    fitAllBox.x1 + fitAllBox.get_width() + fitAllSpacing,
-                    fitAllBox.y1);
+                    fitAllBox.x1 + fitAllWidth + fitAllSpacing,
+                    fitAllY1);
             }
         });
     }


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