Skip to content

Commit

Permalink
optimize: make mntinfo_add_list O(1) by adding a tail pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushT369 committed Feb 4, 2025
1 parent d4585a0 commit 1094c7a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions criu/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,17 @@ static char *ext_mount_lookup(char *key)
* Single linked list of mount points get from proc/images
*/
struct mount_info *mntinfo;
struct mount_info *mntinfo_tail;

static void mntinfo_add_list(struct mount_info *new)
{
if (!mntinfo)
if (!mntinfo) {
mntinfo = new;
mntinfo_tail = mntinfo;
}
else {
struct mount_info *pm;

/* Add to the tail. (FIXME -- make O(1) ) */
for (pm = mntinfo; pm->next != NULL; pm = pm->next)
;
pm->next = new;
mntinfo_tail->next = new;
mntinfo_tail = mntinfo_tail->next;
}
}

Expand Down

0 comments on commit 1094c7a

Please sign in to comment.