git-gui: Use catch rather than array names to check file.
authorShawn O. Pearce <spearce@spearce.org>
Sat, 11 Nov 2006 23:42:42 +0000 (18:42 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 05:16:01 +0000 (00:16 -0500)
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>
git-gui

diff --git a/git-gui b/git-gui
index 2c4e97236b13c4f88532d75b8e086f53025afbee..e16fcf7346165a9646de1262ac5a75b3fcbf706b 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -350,11 +350,11 @@ proc clear_diff {} {
 proc reshow_diff {} {
        global ui_fname_value ui_status_value file_states
 
-       if {$ui_fname_value != {} && [array names file_states \
-               -exact $ui_fname_value] != {}}  {
-               show_diff $ui_fname_value
-       } else {
+       if {$ui_fname_value == {}
+               || [catch {set s $file_states($ui_fname_value)}]} {
                clear_diff
+       } else {
+               show_diff $ui_fname_value
        }
 }