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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1713>
This commit is contained in:
Jonas Dreßler 2021-02-24 12:06:19 +01:00 committed by Marge Bot
parent 0fd394d4ca
commit 7a5650d868

View File

@ -663,6 +663,10 @@ var IconGridLayout = GObject.registerClass({
} }
_getRowPadding(items, itemIndex, childSize, spacing) { _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); const nRows = Math.ceil(items.length / this.columnsPerPage);
let rowAlign = 0; let rowAlign = 0;
@ -682,18 +686,13 @@ var IconGridLayout = GObject.registerClass({
Clutter.get_default_text_direction() === Clutter.TextDirection.RTL; Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
switch (this.lastRowAlign) { switch (this.lastRowAlign) {
case Clutter.ActorAlign.START:
rowAlign = 0;
break;
case Clutter.ActorAlign.CENTER: case Clutter.ActorAlign.CENTER:
rowAlign = availableWidth / 2; rowAlign = availableWidth / 2;
break; break;
case Clutter.ActorAlign.END: case Clutter.ActorAlign.END:
rowAlign = availableWidth; rowAlign = availableWidth;
break; break;
case Clutter.ActorAlign.FILL: // START and FILL align are handled at the beginning of the function
rowAlign = 0;
break;
} }
return isRtl ? rowAlign * -1 : rowAlign; return isRtl ? rowAlign * -1 : rowAlign;