diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-22 14:03:29 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-22 14:28:03 -0700 |
commit | e1980c9d23c22ecfbcadbe91d304ba778b84b457 (patch) | |
tree | c74e41cc363541253732ad7d62ba511a3818d176 /sha1_file.c | |
parent | refs: use strings directly in find_containing_dir() (diff) | |
download | tgif-e1980c9d23c22ecfbcadbe91d304ba778b84b457.tar.xz |
refs: do not create ref_entry when searching
The search_ref_dir() function is about looking up an existing ref_entry in
a sorted array of ref_entry stored in dir->entries, but it still allocates
a new ref_entry and frees it before returning. This is only because the
call to bsearch(3) was coded in a suboptimal way. Unlike the comparison
function given to qsort(3), the first parameter to its comparison function
does not need to point at an object that is shaped like an element in the
array.
Introduce a new comparison function that takes a counted string as the key
and an element in an array of ref_entry and give it to bsearch(), so that
we do not have to allocate a new ref_entry that we will never return to
the caller anyway.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
0 files changed, 0 insertions, 0 deletions