[gnome-shell] workspace: Get some values outside the children loop when allocating
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] workspace: Get some values outside the children loop when allocating
- Date: Tue, 9 Mar 2021 15:48:59 +0000 (UTC)
commit 650e0960a272793b9051afc246015d17b1e20b84
Author: Jonas Dreßler <verdre v0yd nl>
Date: Thu Feb 25 12:13:21 2021 +0100
workspace: Get some values outside the children loop when allocating
It turned out that getting properties and saving them to a variable
outside of loops instead of accessing them everytime inside the loop can
have significant impact on performance, so do that in Workspaces
vfunc_allocate().
Here the impact is not that large, about 0.05 ms with 20 open windows,
that still seems worth it though.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1743>
js/ui/workspace.js | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 8a273e865e..f11f546f1e 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -609,7 +609,12 @@ var WorkspaceLayout = GObject.registerClass({
this._windowSlots = this._getWindowSlots(box.copy());
}
- const allocationScale = containerBox.get_width() / this._workarea.width;
+ const workareaX = this._workarea.x;
+ const workareaY = this._workarea.y;
+ const workareaWidth = this._workarea.width;
+ const stateAdjustementValue = this._stateAdjustment.value;
+
+ const allocationScale = containerBox.get_width() / workareaWidth;
const workspaceBox = new Clutter.ActorBox();
const layoutBox = new Clutter.ActorBox();
@@ -628,16 +633,16 @@ var WorkspaceLayout = GObject.registerClass({
if (windowInfo.metaWindow.showing_on_its_workspace()) {
workspaceBox.set_origin(
- child.boundingBox.x - this._workarea.x,
- child.boundingBox.y - this._workarea.y);
+ child.boundingBox.x - workareaX,
+ child.boundingBox.y - workareaY);
workspaceBox.set_size(
child.boundingBox.width,
child.boundingBox.height);
} else {
- workspaceBox.set_origin(this._workarea.x, this._workarea.y);
+ workspaceBox.set_origin(workareaX, workareaY);
workspaceBox.set_size(0, 0);
- child.opacity = this._stateAdjustment.value * 255;
+ child.opacity = stateAdjustementValue * 255;
}
workspaceBox.scale(allocationScale);
@@ -657,7 +662,7 @@ var WorkspaceLayout = GObject.registerClass({
layoutBox.set_size(width, height);
const childBox = workspaceBox.interpolate(layoutBox,
- this._stateAdjustment.value);
+ stateAdjustementValue);
if (windowInfo.currentTransition) {
windowInfo.currentTransition.get_interval().set_final(childBox);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]