(show_tree): minor optimization.

This commit is contained in:
Andrew Borodin 2014-09-03 10:14:22 +04:00
parent b36adca2d1
commit 21fba120d0

View File

@ -14,7 +14,7 @@
Norbert Warmuth, 1997 Norbert Warmuth, 1997
Miguel de Icaza, 1996, 1999 Miguel de Icaza, 1996, 1999
Slava Zanko <slavazanko@gmail.com>, 2013 Slava Zanko <slavazanko@gmail.com>, 2013
Andrew Borodin <aborodin@vmail.ru>, 2013 Andrew Borodin <aborodin@vmail.ru>, 2013, 2014
This file is part of the Midnight Commander. This file is part of the Midnight Commander.
@ -306,7 +306,6 @@ show_tree (WTree * tree)
i = 0; i = 0;
while (current->prev && i < tree->topdiff) while (current->prev && i < tree->topdiff)
{ {
current = current->prev; current = current->prev;
if (current->sublevel < tree->selected_ptr->sublevel) if (current->sublevel < tree->selected_ptr->sublevel)
@ -324,15 +323,11 @@ show_tree (WTree * tree)
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
i++; i++;
} }
else else if (current->sublevel == tree->selected_ptr->sublevel + 1)
{ {
if (current->sublevel == tree->selected_ptr->sublevel + 1 j = vfs_path_len (tree->selected_ptr->name);
&& vfs_path_len (tree->selected_ptr->name) > 1) if (j > 1 && vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
{ i++;
if (vfs_path_equal_len (current->name, tree->selected_ptr->name,
vfs_path_len (tree->selected_ptr->name)))
i++;
}
} }
} }
tree->topdiff = i; tree->topdiff = i;