From f5bbc36a915036f5ee8738eb71162cb467fa5f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Dejean?= Date: Wed, 17 Oct 2007 20:52:50 +0000 Subject: [PATCH] Little performance tuning to avoid too many array reallocation. svn path=/trunk/; revision=2682 --- sysdeps/linux/mountlist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysdeps/linux/mountlist.c b/sysdeps/linux/mountlist.c index b013bbd5..cc6b797c 100644 --- a/sysdeps/linux/mountlist.c +++ b/sysdeps/linux/mountlist.c @@ -119,7 +119,10 @@ glibtop_get_mountlist_s(glibtop *server, glibtop_mountlist *buf, int all_fs) glibtop_init_r(&server, 0, 0); memset(buf, 0, sizeof(glibtop_mountlist)); - entries = g_array_new(FALSE, FALSE, sizeof(glibtop_mountentry)); + /* wild guess, preallocate 8 entries + on a desktop, almost everyone has / and a tmpfs for udev + if all_fs, there are also proc, sys, fuse, binfmt, etc */ + entries = g_array_sized_new(FALSE, FALSE, sizeof(glibtop_mountentry), 8); if (!(fp = setmntent(MOUNTED, "r"))) { glibtop_warn_io_r(server, "Could not open %s", MOUNTED);