]> git.ipfire.org Git - thirdparty/git.git/commit - commit.c
commit-slab: introduce slabname##_peek() function
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 May 2015 22:25:52 +0000 (15:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 May 2015 21:40:30 +0000 (14:40 -0700)
commit862e730ec1c13f28bfb7c8c9ecb39bcc92dd0922
tree83f241cbdd890926053221fd0932ab6d47217108
parent282616c72d1d08a77ca4fe1186cb708c38408d87
commit-slab: introduce slabname##_peek() function

There is no API to ask "Does this commit have associated data in
slab?".  If an application wants to (1) parse just a few commits at
the beginning of a process, (2) store data for only these commits,
and then (3) start processing many commits, taking into account the
data stored (for a few of them) in the slab, the application would
use slabname##_at() to allocate a space to store data in (2), but
there is no API other than slabname##_at() to use in step (3).  This
allocates and wastes new space for these commits the caller is only
interested in checking if they have data stored in step (2).

Introduce slabname##_peek(), which is similar to slabname##_at() but
returns NULL when there is no data already associated to it in such
a use case.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-slab.h
commit.c