From dff1344a1ca4b5e65e0ad67a1aa57ffbe34a8d67 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 28 Feb 2021 15:45:37 +0300 Subject: [PATCH 1/2] windowPreview: Replace for..of with regular for Reduces average ControlsManagerLayout.allocate from 3.7 ms to 3.4 ms. --- js/ui/windowPreview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js index a27d0586f4..b51171465d 100644 --- a/js/ui/windowPreview.js +++ b/js/ui/windowPreview.js @@ -85,7 +85,10 @@ var WindowPreviewLayout = GObject.registerClass({ const childBox = new Clutter.ActorBox(); - for (const child of container) { + const children = container.get_children(); + const nChildren = children.length; + for (let index = 0; index < nChildren; index++) { + const child = children[index]; if (!child.visible) continue; -- GitLab From 219912095a524f5697dab385f54e5de09ae9458b Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 28 Feb 2021 15:49:38 +0300 Subject: [PATCH 2/2] windowPreview: Replace unpacking with indexed access Reduces average ControlsManagerLayout.allocate from 3.44 ms to 3.41 ms. --- js/ui/windowPreview.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js index b51171465d..f9922f2806 100644 --- a/js/ui/windowPreview.js +++ b/js/ui/windowPreview.js @@ -99,7 +99,9 @@ var WindowPreviewLayout = GObject.registerClass({ bufferRect.x - this._boundingBox.x1, bufferRect.y - this._boundingBox.y1); - const [, , natWidth, natHeight] = child.get_preferred_size(); + const size = child.get_preferred_size(); + const natWidth = size[2]; + const natHeight = size[3]; childBox.set_size(natWidth, natHeight); childBox.x1 *= scaleX; -- GitLab