From 8fefe2b9335cb0879b24327eff4296543b474ac8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 28 Jul 2026 17:37:30 +0200 Subject: [PATCH] Cleanup: move variable assignment out of the loop It never changes inside this function, so there's no need to recompute it with every loop iteration. Equivalent to the change that was made to isDescendentOfSelectedNodes in files_controller.go in d0c6e27fee9b4. --- pkg/gui/controllers/commits_files_controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index d129b3f90..5d4377fe1 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -642,9 +642,10 @@ func normalisedSelectedCommitFileNodes(selectedNodes []*filetree.CommitFileNode) } func isDescendentOfSelectedCommitFileNodes(node *filetree.CommitFileNode, selectedNodes []*filetree.CommitFileNode) bool { + nodePath := node.GetPath() + for _, selectedNode := range selectedNodes { selectedNodePath := selectedNode.GetPath() - nodePath := node.GetPath() if strings.HasPrefix(nodePath, selectedNodePath) && nodePath != selectedNodePath { return true