summaryrefslogtreecommitdiff
path: root/builtin/cat-file.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-14 18:14:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-14 19:27:53 (GMT)
commitced9fff75dad2578d7583ba3085970b03c66c57b (patch)
treeb73d1184e775ad9e276916dc9ea1c42efcd00f8e /builtin/cat-file.c
parent0750bb5b51f021ecad6f33b7ec88cdfc2a8cdff4 (diff)
downloadgit-ced9fff75dad2578d7583ba3085970b03c66c57b.zip
git-ced9fff75dad2578d7583ba3085970b03c66c57b.tar.gz
git-ced9fff75dad2578d7583ba3085970b03c66c57b.tar.bz2
cat-file: use oidset check-and-insert
We don't need to check if the oidset has our object before we insert it; that's done as part of the insertion. We can just rely on the return value from oidset_insert(), which saves one hash lookup per object. This measurable speedup is tiny and within the run-to-run noise, but the result is simpler to read, too. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r--builtin/cat-file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 45992c9..04b5cda 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -443,9 +443,8 @@ static int batch_unordered_object(const struct object_id *oid, void *vdata)
{
struct object_cb_data *data = vdata;
- if (oidset_contains(data->seen, oid))
+ if (oidset_insert(data->seen, oid))
return 0;
- oidset_insert(data->seen, oid);
return batch_object_cb(oid, data);
}