From 7a5650d8682860bc40d3679e3752e5fccc876661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 24 Feb 2021 12:06:19 +0100 Subject: [PATCH] iconGrid: Bail out of getRowPadding early if we'll return 0 This gets our time spent in vfunc_allocate() down again by ~0.1 ms from 1.4 ms to 1.3 ms. Part-of: --- js/ui/iconGrid.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 27ffd733e..8f6b54701 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -663,6 +663,10 @@ var IconGridLayout = GObject.registerClass({ } _getRowPadding(items, itemIndex, childSize, spacing) { + if (this.lastRowAlign === Clutter.ActorAlign.START || + this.lastRowAlign === Clutter.ActorAlign.FILL) + return 0; + const nRows = Math.ceil(items.length / this.columnsPerPage); let rowAlign = 0; @@ -682,18 +686,13 @@ var IconGridLayout = GObject.registerClass({ Clutter.get_default_text_direction() === Clutter.TextDirection.RTL; switch (this.lastRowAlign) { - case Clutter.ActorAlign.START: - rowAlign = 0; - break; case Clutter.ActorAlign.CENTER: rowAlign = availableWidth / 2; break; case Clutter.ActorAlign.END: rowAlign = availableWidth; break; - case Clutter.ActorAlign.FILL: - rowAlign = 0; - break; + // START and FILL align are handled at the beginning of the function } return isRtl ? rowAlign * -1 : rowAlign;