Thread (1 message) 1 message, 1 author, 2016-10-16

Re: [PATCH v2 2/6] trailer: use list.h for doubly-linked list

From: Junio C Hamano <hidden>
Date: 2016-10-16 00:33:40

Jonathan Tan [off-list ref] writes:
Replace the existing handwritten implementation of a doubly-linked list
in trailer.c with the functions and macros from list.h. This
significantly simplifies the code.
---
The handcrafted one in trailer.c somehow did not use the common
practice of using a doubly-linked cycle as a doubly-linked list with
a designated fake element as the pointers to the first and to the
last elements of the list (instead it used NULL as the "this is the
end in this direction" convention just like a common singly-linked
list), and this update removes the need for special cases handling
the elements at the beginning and at the end that comes from that
choice by switching to list.h macros.  update_last/update_first can
go, two parameters that were passed to point at the variables for
the beginning and the end can go, the special cases for the initial
condition in add_trailer_item() can go, all thanks to this change.

Very nice.
 trailer.c | 258 ++++++++++++++++++++++----------------------------------------
 1 file changed, 91 insertions(+), 167 deletions(-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help