Removed get_pageshift(). Every one can affort a * instead of a >>, no need

* glibtop_server.c:
	* glibtop_server.h:
	* procmem.c: (glibtop_get_proc_mem_s):
	* procsegment.c: (glibtop_get_proc_segment_s): Removed get_pageshift().
	Every one can affort a * instead of a >>, no need for this kind of
	non-reentrant optimization. Saved 144B (obviously perfect cleanup ;)
This commit is contained in:
Benoît Dejean
2004-09-23 08:13:28 +00:00
parent c29887d4b0
commit 61889bc182
5 changed files with 19 additions and 32 deletions

View File

@@ -1,3 +1,12 @@
2004-09-23 Benoît Dejean <tazforever@dlfp.org>
* glibtop_server.c:
* glibtop_server.h:
* procmem.c: (glibtop_get_proc_mem_s):
* procsegment.c: (glibtop_get_proc_segment_s): Removed get_pageshift().
Every one can affort a * instead of a >>, no need for this kind of
non-reentrant optimization. Saved 144B (obviously perfect cleanup ;)
2004-09-22 Benoît Dejean <tazforever@dlfp.org> 2004-09-22 Benoît Dejean <tazforever@dlfp.org>
* glibtop_server.c: Removed #warning, my gcc is not buggy anymore. * glibtop_server.c: Removed #warning, my gcc is not buggy anymore.

View File

@@ -9,9 +9,6 @@
#include <fcntl.h> #include <fcntl.h>
/* gcc warning bug */
unsigned get_pageshift(void);
unsigned long long unsigned long long
get_scaled(const char *buffer, const char *key) get_scaled(const char *buffer, const char *key)
@@ -85,20 +82,3 @@ file_to_buffer(glibtop *server, char *buffer, const char *filename)
} }
unsigned get_pageshift(void)
{
static unsigned pageshift = 0;
if(G_UNLIKELY(!pageshift))
{
register unsigned pagesize = getpagesize();
while( pagesize > 1 )
{
pagesize >>= 1;
pageshift++;
}
}
return pageshift;
}

View File

@@ -39,8 +39,6 @@ G_BEGIN_DECLS
#define LINUX_VERSION_CODE(x,y,z) (0x10000*(x) + 0x100*(y) + z) #define LINUX_VERSION_CODE(x,y,z) (0x10000*(x) + 0x100*(y) + z)
unsigned get_pageshift(void);
static inline char* static inline char*
next_token(const char *p) next_token(const char *p)
{ {

View File

@@ -49,7 +49,7 @@ void
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
{ {
char buffer [BUFSIZ], *p; char buffer [BUFSIZ], *p;
const unsigned pageshift = get_pageshift(); const size_t pagesize = getpagesize();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
@@ -76,10 +76,10 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
buf->resident = strtoull (p, &p, 0); buf->resident = strtoull (p, &p, 0);
buf->share = strtoull (p, &p, 0); buf->share = strtoull (p, &p, 0);
buf->size <<= pageshift; buf->size *= pagesize;
buf->resident <<= pageshift; buf->resident *= pagesize;
buf->share <<= pageshift; buf->share *= pagesize;
buf->rss <<= pageshift; buf->rss *= pagesize;
buf->flags |= _glibtop_sysdeps_proc_mem_statm; buf->flags |= _glibtop_sysdeps_proc_mem_statm;
} }

View File

@@ -53,7 +53,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid) pid_t pid)
{ {
char buffer [BUFSIZ], *p; char buffer [BUFSIZ], *p;
const unsigned pageshift = get_pageshift(); const size_t pagesize = getpagesize();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
@@ -86,10 +86,10 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
buf->data_rss = strtoull (p, &p, 0); buf->data_rss = strtoull (p, &p, 0);
buf->dirty_size = strtoull (p, &p, 0); buf->dirty_size = strtoull (p, &p, 0);
buf->text_rss <<= pageshift; buf->text_rss *= pagesize;
buf->shlib_rss <<= pageshift; buf->shlib_rss *= pagesize;
buf->data_rss <<= pageshift; buf->data_rss *= pagesize;
buf->dirty_size <<= pageshift; buf->dirty_size *= pagesize;
buf->flags |= _glibtop_sysdeps_proc_segment_statm; buf->flags |= _glibtop_sysdeps_proc_segment_statm;
} }