summaryrefslogtreecommitdiff
path: root/contrib/vscode
diff options
context:
space:
mode:
authorLibravatar Taylor Blau <me@ttaylorr.com>2021-08-29 22:48:57 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-08-29 23:25:43 -0700
commitb0173340c6b5fb330f5ea22504389fc6c5367f14 (patch)
treeaa3de0043a2c513913836419e9d8eb3dd6dc266a /contrib/vscode
parentbuiltin/pack-objects.c: simplify add_objects_in_unpacked_packs() (diff)
downloadtgif-b0173340c6b5fb330f5ea22504389fc6c5367f14.tar.xz
builtin/pack-objects.c: remove duplicate hash lookup
In the original code from 08cdfb1337 (pack-objects --keep-unreachable, 2007-09-16), we add each object to the packing list with type `obj->type`, where `obj` comes from `lookup_unknown_object()`. Unless we had already looked up and parsed the object, this will be `OBJ_NONE`. That's fine, since oe_set_type() sets the type_valid bit to '0', and we determine the real type later on. So the only thing we need from the object lookup is access to the `flags` field so that we can mark that we've added the object with `OBJECT_ADDED` to avoid adding it again (we can just pass `OBJ_NONE` directly instead of grabbing it from the object). But add_object_entry() already rejects duplicates! This has been the behavior since 7a979d99ba (Thin pack - create packfile with missing delta base., 2006-02-19), but 08cdfb1337 didn't take advantage of it. Moreover, to do the OBJECT_ADDED check, we have to do a hash lookup in `obj_hash`. So we can drop the lookup_unknown_object() call completely, *and* the OBJECT_ADDED flag, too, since the spot we're touching here is the only location that checks it. In the end, we perform the same number of hash lookups, but with the added bonus that we don't waste memory allocating an OBJ_NONE object (if we were traversing, we'd need it eventually, but the whole point of this code path is not to traverse). Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/vscode')
0 files changed, 0 insertions, 0 deletions