Skip to content

Commit e369dbe

Browse files
mark987j6t
authored andcommitted
git-gui: simplify PATH de-duplication
git-gui since 8fe7861 ("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 <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent e3923e3 commit e369dbe

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

git-gui.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ if {[is_Windows]} {
103103
set _path_sep {:}
104104
}
105105

106-
set _search_path {}
107106
set _path_seen [dict create]
108107
foreach p [split $env(PATH) $_path_sep] {
109108
# Keep only absolute paths, getting rid of ., empty, etc.
@@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] {
112111
}
113112
# Keep only the first occurence of any duplicates.
114113
set norm_p [file normalize $p]
115-
if {[dict exists $_path_seen $norm_p]} {
116-
continue
117-
}
118114
dict set _path_seen $norm_p 1
119-
lappend _search_path $norm_p
120115
}
116+
set _search_path [dict keys $_path_seen]
121117
unset _path_seen
122118

123119
set env(PATH) [join $_search_path $_path_sep]

0 commit comments

Comments
 (0)