summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-12-01 07:53:48 +0100
committerYorhel <git@yorhel.nl>2018-12-01 07:53:51 +0100
commitbf8068b65ebdc85770fa8b8eb713c3fe3b2aae4a (patch)
treea0eb8ae8a0237151ddad029c5bdf172b471f217e
parentd95c65b032e0b4b0ff727673755eabc44a51e8ff (diff)
Slightly improve hardlink circular list insertion performance
Based on https://dev.yorhel.nl/ncdu/bug/124
-rw-r--r--src/dir_mem.c6
1 files 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;
}