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>
This commit is contained in:
Jonas Dreßler 2021-03-09 18:12:02 +01:00 committed by Marge Bot
parent c239cd398d
commit 9152d6613b

View File

@ -367,6 +367,11 @@ class WorkspacesView extends WorkspacesViewBase {
if (rtl) if (rtl)
workspaces.reverse(); 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 => { workspaces.forEach(child => {
if (fitMode === FitMode.SINGLE) if (fitMode === FitMode.SINGLE)
box = fitSingleBox; box = fitSingleBox;
@ -379,18 +384,18 @@ class WorkspacesView extends WorkspacesViewBase {
if (vertical) { if (vertical) {
fitSingleBox.set_origin( fitSingleBox.set_origin(
fitSingleBox.x1, fitSingleX1,
fitSingleBox.y1 + fitSingleBox.get_height() + fitSingleSpacing); fitSingleBox.y1 + fitSingleHeight + fitSingleSpacing);
fitAllBox.set_origin( fitAllBox.set_origin(
fitAllBox.x1, fitAllX1,
fitAllBox.y1 + fitAllBox.get_height() + fitAllSpacing); fitAllBox.y1 + fitAllHeight + fitAllSpacing);
} else { } else {
fitSingleBox.set_origin( fitSingleBox.set_origin(
fitSingleBox.x1 + fitSingleBox.get_width() + fitSingleSpacing, fitSingleBox.x1 + fitSingleWidth + fitSingleSpacing,
fitSingleBox.y1); fitSingleY1);
fitAllBox.set_origin( fitAllBox.set_origin(
fitAllBox.x1 + fitAllBox.get_width() + fitAllSpacing, fitAllBox.x1 + fitAllWidth + fitAllSpacing,
fitAllBox.y1); fitAllY1);
} }
}); });
} }