From bf8068b65ebdc85770fa8b8eb713c3fe3b2aae4a Mon Sep 17 00:00:00 2001 From: Yorhel <git@yorhel.nl> Date: Sat, 1 Dec 2018 07:53:48 +0100 Subject: [PATCH] Slightly improve hardlink circular list insertion performance Based on https://dev.yorhel.nl/ncdu/bug/124 --- src/dir_mem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dir_mem.c b/src/dir_mem.c index 6930b2b..5007980 100644 --- a/src/dir_mem.c +++ b/src/dir_mem.c @@ -67,10 +67,8 @@ static void hlink_check(struct dir *d) { /* found in the table? update hlnk */ if(!i) { - t = d->hlnk = kh_key(links, k); - if(t->hlnk != NULL) - for(t=t->hlnk; t->hlnk!=d->hlnk; t=t->hlnk) - ; + t = kh_key(links, k); + d->hlnk = t->hlnk == NULL ? t : t->hlnk; t->hlnk = d; } -- GitLab