summaryrefslogtreecommitdiff
path: root/versioncmp.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2019-09-05 21:36:05 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-09-06 11:03:42 -0700
commit3a37876b5dca4c18bda67bcdead9c1d79a59933d (patch)
tree56e4477811ed88a2510d65acc3eb33755563825e /versioncmp.c
parenttest-read-cache: drop namelen variable (diff)
downloadtgif-3a37876b5dca4c18bda67bcdead9c1d79a59933d.tar.xz
pack-objects: drop packlist index_pos optimization
Once upon a time, the code to add an object to our packing list in pack-objects all lived in a single function. It computed the position within the hash table once, then used it to check if the object was already present, and if not, to add it. Later, in 2834bc27c1 (pack-objects: refactor the packing list, 2013-10-24), this was split into two functions: packlist_find() and packlist_alloc(). We ended up with an "index_pos" variable that gets passed through several functions to make it from one to the other. The resulting code is rather confusing to follow. The "index_pos" variable is sometimes undefined, if we don't yet have a hash table. This works out in practice because in that case packlist_alloc() won't use it at all, since it will have to create/grow the hash table. But it's hard to verify that, and it does cause gcc 9.2.1's -Wmaybe-uninitialized to complain when compiled with "-flto -O3" (rightfully, since we do pass the uninitialized value as a function parameter, even if nobody ends up using it). All of this is to save computing the hash index again when we're inserting into the hash table, which I found doesn't make a measurable difference in the program runtime (which is not surprising, since we're doing all kinds of other heavyweight things for each object). Let's just drop this index_pos variable entirely, simplifying the code (and pleasing the compiler). We might be better still refactoring this custom hash table to use one of our existing implementations (an oidmap, or a kh_oid_map). I stopped short of that here, but this would be the likely first step towards that anyway. Reported-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'versioncmp.c')
0 files changed, 0 insertions, 0 deletions