From c2618088c6c334c8551e16440a6dcbcb99df3b62 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 23 Jan 2024 14:08:20 -0500 Subject: [PATCH] Reduce unneeded iterations in indentSubtractor --- src/entryList.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/entryList.go b/src/entryList.go index 06e7dd7..e420cef 100644 --- a/src/entryList.go +++ b/src/entryList.go @@ -20,11 +20,11 @@ const ( ) // calculates and returns the final visual indentation multiplier (needed to adjust indentation for skipped parent directories) -func indentSubtractor(indent int, skippedDirList []bool, currentIndex int) int { +func indentSubtractor(indent int, skippedDirList []bool, currentDirIndex int) int { var subtractor int // tracks how much to subtract from expected indentation multiplier - for i, skipped := range skippedDirList { // checks each skipped directory to determine if it is a parent to the current directory - if skipped && strings.HasPrefix(dirList[currentIndex], dirList[i]+PathSeparator) { + for i := len(skippedDirList[:currentDirIndex]) - 1; i >= 0; i-- { // checks each skipped directory to determine if it is a parent to the current directory + if skippedDirList[i] && strings.HasPrefix(dirList[currentDirIndex], dirList[i]+PathSeparator) { subtractor++ // if the skipped directory is a parent, increment the subtractor } }