author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Fri, 25 Mar 2011 09:34:20 +0000 (16:34 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 25 Mar 2011 16:20:33 +0000 (09:20 -0700) | ||
commit | 97d0b74a49f0c81c3f9673c1a17721ac0624c3df | |
tree | c4e7b7b6f2083cb9abf6a1cd7d97c0e693203744 | tree | snapshot |
parent | f0096c06bcdeb7aa6ae8a749ddc9d6d4a2c381d1 | commit | diff |
Improve tree_entry_interesting() handling code
t_e_i() can return -1 or 2 to early shortcut a search. Current code
may use up to two variables to handle it. One for saving return value
from t_e_i temporarily, one for saving return code 2.
The second variable is not needed. If we make sure the first variable
does not change until the next t_e_i() call, then we can do something
like this:
int ret = 0;
while (...) {
if (ret != 2) {
ret = t_e_i();
if (ret < 0) /* no longer interesting */
break;
if (ret == 0) /* skip this round */
continue;
}
/* ret > 0, interesting */
}
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t_e_i() can return -1 or 2 to early shortcut a search. Current code
may use up to two variables to handle it. One for saving return value
from t_e_i temporarily, one for saving return code 2.
The second variable is not needed. If we make sure the first variable
does not change until the next t_e_i() call, then we can do something
like this:
int ret = 0;
while (...) {
if (ret != 2) {
ret = t_e_i();
if (ret < 0) /* no longer interesting */
break;
if (ret == 0) /* skip this round */
continue;
}
/* ret > 0, interesting */
}
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c | diff | blob | history | |
list-objects.c | diff | blob | history | |
tree-diff.c | diff | blob | history |