@matheusbsbs / matheus-bagliano / commits / 73ad179bbb
Fork 0

git-gui: Use catch rather than array names to check file.

When we reshow the current diff file it can be faster to just fetch the value from the file_states array than it is to ask for all paths whose name exactly matches the one we want to show. This is because [array names -exact] is O(n) in the number of files. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 11, 2006 at 18:42 UTC 73ad179bbbba56c053045c555b7e5f1882380533
1 file changed +4 -4
git-gui
+4 -4
@@ -350,11 +350,11 @@ proc clear_diff {} {
350 proc reshow_diff {} {
351 global ui_fname_value ui_status_value file_states
352
353 - if {$ui_fname_value != {} && [array names file_states \
354 - -exact $ui_fname_value] != {}} {
355 - show_diff $ui_fname_value
356 - } else {
353 + if {$ui_fname_value == {}
354 + || [catch {set s $file_states($ui_fname_value)}]} {
355 clear_diff
356 + } else {
357 + show_diff $ui_fname_value
358 }
359 }
360