From: Mark Levedahl <mlevedahl@gmail•com>
To: git@vger•kernel.org
Cc: j6t@kdbg•org, Mark Levedahl <mlevedahl@gmail•com>
Subject: [PATCH] git-gui: simplify PATH de-duplication
Date: Wed, 20 Aug 2025 11:31:43 -0400 [thread overview]
Message-ID: <20250820153143.21181-1-mlevedahl@gmail.com> (raw)
git-gui since 8fe7861c51 ("git-gui: assure PATH has only absolute
elements.", 2025-04-11) uses a list to maintain order and a dict to
detect duplicated elements without quadratic complexity. But, Tcl's
dict explicitly maintains keys in the order first added, thus the list
is not needed. Simplify the code.
Signed-off-by: Mark Levedahl <mlevedahl@gmail•com>
---
git-gui.sh | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index b64d065..4528b22 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -103,21 +103,16 @@ if {[is_Windows]} {
set _path_sep {:}
}
-set _search_path {}
set _path_seen [dict create]
foreach p [split $env(PATH) $_path_sep] {
# Keep only absolute paths, getting rid of ., empty, etc.
if {[file pathtype $p] ne {absolute}} {
continue
}
- # Keep only the first occurence of any duplicates.
set norm_p [file normalize $p]
- if {[dict exists $_path_seen $norm_p]} {
- continue
- }
dict set _path_seen $norm_p 1
- lappend _search_path $norm_p
}
+set _search_path [dict keys $_path_seen]
unset _path_seen
set env(PATH) [join $_search_path $_path_sep]
--
2.51.0.99.15
next reply other threads:[~2025-08-20 15:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 15:31 Mark Levedahl [this message]
2025-08-21 18:39 ` [PATCH] git-gui: simplify PATH de-duplication Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250820153143.21181-1-mlevedahl@gmail.com \
--to=mlevedahl@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=j6t@kdbg$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox