Replaced two strstr by a hand-written loop in this critical code.

2007-01-11  Benoît Dejean  <benoit@placenet.org>

	* glibtop_private.c: (get_scaled):
	
	Replaced two strstr by a hand-written loop in this critical code.

svn path=/trunk/; revision=2544
This commit is contained in:
Benoît Dejean
2007-01-11 20:28:02 +00:00
committed by Benoît Dejean
parent 63fb94127a
commit b411ee115f
2 changed files with 16 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
2007-01-11 Benoît Dejean <benoit@placenet.org>
* glibtop_private.c: (get_scaled):
Replaced two strstr by a hand-written loop in this critical code.
2006-09-11 Benoît Dejean <benoit@placenet.org> 2006-09-11 Benoît Dejean <benoit@placenet.org>
* procmap.c: (glibtop_get_proc_map_s): * procmap.c: (glibtop_get_proc_map_s):

View File

@@ -25,10 +25,16 @@ get_scaled(const char *buffer, const char *key)
{ {
ptr += strlen(key); ptr += strlen(key);
value = strtoull(ptr, &next, 0); value = strtoull(ptr, &next, 0);
if (strchr(next, 'k'))
value *= 1024; for ( ; *next; ++next) {
else if (strchr(next, 'M')) if (*next == 'k') {
value *= 1024 * 1024; value *= 1024;
break;
} else if (*next == 'M') {
value *= 1024 * 1024;
break;
}
}
} else } else
g_warning("Could not read key '%s' in buffer '%s'", g_warning("Could not read key '%s' in buffer '%s'",
key, buffer); key, buffer);