diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-01-28 13:55:59 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-02-03 16:33:13 -0800 |
commit | a77a48c259d9adbe7779ca69a3432e493116b3fd (patch) | |
tree | a9099ecbe7fa703c85a6e2662019918780b15e5c /branch.c | |
parent | dc5705d77f5af53f9fa6d8bc40b24123d6e97580 (diff) | |
download | git-ks/diff-c-with-diff-order.tar.gz |
combine-diff: simplify intersect_paths() furtherks/diff-c-with-diff-order
Linus once said:
I actually wish more people understood the really core low-level
kind of coding. Not big, complex stuff like the lockless name
lookup, but simply good use of pointers-to-pointers etc. For
example, I've seen too many people who delete a singly-linked
list entry by keeping track of the "prev" entry, and then to
delete the entry, doing something like
if (prev)
prev->next = entry->next;
else
list_head = entry->next;
and whenever I see code like that, I just go "This person
doesn't understand pointers". And it's sadly quite common.
People who understand pointers just use a "pointer to the entry
pointer", and initialize that with the address of the
list_head. And then as they traverse the list, they can remove
the entry without using any conditionals, by just doing a "*pp =
entry->next".
Applying that simplification lets us lose 7 lines from this function
even while adding 2 lines of comment.
I was tempted to squash this into the original commit, but because
the benchmarking described in the commit log is without this
simplification, I decided to keep it a separate follow-up patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.c')
0 files changed, 0 insertions, 0 deletions