Cached boot_time.

* glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time.
This commit is contained in:
Benoît Dejean
2005-07-07 19:34:18 +00:00
parent f409c553f5
commit 16e0c943b2
2 changed files with 22 additions and 2 deletions

View File

@@ -1,3 +1,7 @@
2005-07-07 Benoît Dejean <TazForEver@dlfp.org>
* glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time.
2005-07-06 Benoît Dejean <TazForEver@dlfp.org>
Et m***e ... CVS got me. I wanted to commit a single change on the

View File

@@ -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;
}