refs_ref_iterator_begin(): don't check prefixes redundantly

The backend already correctly restricts its output to references whose
names start with the prefix. By passing the prefix again to
`prefix_ref_iterator`, we were forcing that iterator to do redundant
prefix comparisons. So set it to the empty string.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2017-05-22 16:17:36 +02:00 коммит произвёл Junio C Hamano
Родитель b9c8e7f2fb
Коммит c759971816
1 изменённых файлов: 7 добавлений и 1 удалений

8
refs.c
Просмотреть файл

@ -1247,7 +1247,13 @@ struct ref_iterator *refs_ref_iterator_begin(
struct ref_iterator *iter;
iter = refs->be->iterator_begin(refs, prefix, flags);
iter = prefix_ref_iterator_begin(iter, prefix, trim);
/*
* `iterator_begin()` already takes care of prefix, but we
* might need to do some trimming:
*/
if (trim)
iter = prefix_ref_iterator_begin(iter, "", trim);
return iter;
}