From edbbf2082c73e70a9d384eb2feb05cab6401651a Mon Sep 17 00:00:00 2001 From: lwouis Date: Thu, 26 Mar 2026 22:20:23 +0100 Subject: [PATCH] perf: improve badges retrieval --- src/logic/Applications.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logic/Applications.swift b/src/logic/Applications.swift index f62200c2..b88056c4 100644 --- a/src/logic/Applications.swift +++ b/src/logic/Applications.swift @@ -124,8 +124,8 @@ class Applications { AXUIElement.retryAxCallUntilTimeout(callType: .updateDockBadgesFromShowingUi) { guard let dockPid = (list.first { $0.bundleIdentifier == "com.apple.dock" }?.pid), let axDockChildren = try AXUIElementCreateApplication(dockPid).attributes([kAXChildrenAttribute]).children, - let axList = try (axDockChildren.first { try $0.attributes([kAXRoleAttribute]).role == kAXListRole }), - let axListChildren = try axList.attributes([kAXChildrenAttribute]).children else { return } + let axListAttrs = (axDockChildren.lazy.compactMap { try? $0.attributes([kAXRoleAttribute, kAXChildrenAttribute]) }.first { $0.role == kAXListRole }), + let axListChildren = axListAttrs.children else { return } let axAppDockItemUrlAndLabel: [(URL?, String?)] = try axListChildren.compactMap { let a = try $0.attributes([kAXSubroleAttribute, kAXIsApplicationRunningAttribute, kAXURLAttribute, kAXStatusLabelAttribute]) guard a.subrole == kAXApplicationDockItemSubrole && (a.appIsRunning ?? false) else { return nil }