• Junio C Hamano's avatar
    commit-slab: introduce slabname##_peek() function · 862e730e
    Junio C Hamano authored
    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: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
commit-slab.h 4.79 KB