From 16e0c943b233589eae09b8307099a17b0c642997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Dejean?= Date: Thu, 7 Jul 2005 19:34:18 +0000 Subject: [PATCH] Cached boot_time. * glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time. --- sysdeps/linux/ChangeLog | 4 ++++ sysdeps/linux/glibtop_private.c | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 00eec6e1..605ab882 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,7 @@ +2005-07-07 Benoît Dejean + + * glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time. + 2005-07-06 Benoît Dejean Et m***e ... CVS got me. I wanted to commit a single change on the diff --git a/sysdeps/linux/glibtop_private.c b/sysdeps/linux/glibtop_private.c index 32d7462b..645b14c3 100644 --- a/sysdeps/linux/glibtop_private.c +++ b/sysdeps/linux/glibtop_private.c @@ -98,8 +98,8 @@ file_to_buffer(glibtop *server, char *buffer, const char *filename) -unsigned long -get_boot_time(glibtop *server) +static unsigned long +read_boot_time(glibtop *server) { char buffer[BUFSIZ]; char *btime; @@ -113,3 +113,19 @@ get_boot_time(glibtop *server) btime = skip_token(btime); return strtoul(btime, NULL, 10); } + + + +unsigned long +get_boot_time(glibtop *server) +{ + static unsigned long boot_time = 0UL; + + if(G_UNLIKELY(!boot_time)) + { + boot_time = read_boot_time(server); + } + + return boot_time; +} +