]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-file.c
delta_base_cache: use list.h for LRU
authorJeff King <peff@peff.net>
Mon, 22 Aug 2016 21:59:42 +0000 (17:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Aug 2016 21:52:00 +0000 (14:52 -0700)
commit12d95ef6fcc1f0b83b24e926f488c6416c08d79c
tree06bbfe3fb4dee00769d8aa9e2e0655d69ce21b32
parentf92dd60f95c3e92bc1eac7a0810efae167df9b51
delta_base_cache: use list.h for LRU

We keep an LRU list of entries for when we need to drop
something from an over-full cache. The list is implemented
as a circular doubly-linked list, which is exactly what
list.h provides. We can save a few lines by using the list.h
macros and functions. More importantly, this makes the code
easier to follow, as the reader sees explicit concepts like
"list_add_tail()" instead of pointer manipulation.

As a bonus, the list_entry() macro lets us place the lru
pointers anywhere inside the delta_base_cache_entry struct
(as opposed to just casting the pointer, which requires it
at the front of the struct). This will be useful in later
patches when we need to place other items at the front of
the struct (e.g., our hashmap implementation requires this).

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