From 34af34af6daa3332db829661dc6546bd576ba319 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Sat, 20 Jun 2026 23:42:40 +0300 Subject: [PATCH] perf: avoid intermediate allocation in bottomNavKeys (#184) Replaces `.map { ... }.toSet()` with `.mapTo(mutableSetOf()) { ... }` when resolving `bottomNavKeys` to avoid creating and discarding an intermediate `ArrayList` during recomposition. --- app/src/main/java/com/m57/hermescontrol/Navigation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/m57/hermescontrol/Navigation.kt b/app/src/main/java/com/m57/hermescontrol/Navigation.kt index e3b2896a..13f4404f 100644 --- a/app/src/main/java/com/m57/hermescontrol/Navigation.kt +++ b/app/src/main/java/com/m57/hermescontrol/Navigation.kt @@ -197,7 +197,7 @@ fun MainNavigation(sessionId: String? = null) { // recomposes and reflects choices instantly. val bottomNavItemsState by AuthManager.bottomNavItemsFlow.collectAsState() val bottomNavItems = resolveBottomNavItems(bottomNavItemsState) - val bottomNavKeys = remember(bottomNavItems) { bottomNavItems.map { it.key }.toSet() } + val bottomNavKeys = remember(bottomNavItems) { bottomNavItems.mapTo(mutableSetOf()) { it.key } } // Sync primary screens to NavigationController LaunchedEffect(bottomNavKeys) {