]> git.ozlabs.org Git - ccan-lca-2011.git/blobdiff - ccan/tdb2/free.c
tdb2: trivial optimization for free list
[ccan-lca-2011.git] / ccan / tdb2 / free.c
index 816d0ee540b3fe81f9fa2f8c4f40561442aab732..dca8ff10709c81e3848b0c1fb9e3e4431ed0996f 100644 (file)
@@ -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;