From: Rusty Russell Date: Tue, 23 Nov 2010 02:21:18 +0000 (+1030) Subject: tdb2: trivial optimization for free list X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=afc3c1e723b4eca0b32f7c5b656f5b070eb1c9fb tdb2: trivial optimization for free list We currently only have one, so shortcut the case where we want our current one. --- diff --git a/ccan/tdb2/free.c b/ccan/tdb2/free.c index 816d0ee5..dca8ff10 100644 --- a/ccan/tdb2/free.c +++ b/ccan/tdb2/free.c @@ -244,12 +244,15 @@ static size_t record_leftover(size_t keylen, size_t datalen, return leftover; } -/* FIXME: Shortcut common case where tdb->flist == flist */ static tdb_off_t flist_offset(struct tdb_context *tdb, unsigned int flist) { - tdb_off_t off = first_flist(tdb); + tdb_off_t off; unsigned int i; + if (likely(tdb->flist == flist)) + return tdb->flist_off; + + off = first_flist(tdb); for (i = 0; i < flist; i++) off = next_flist(tdb, off); return off;