mpc: optimize HZ retrieval

As Brian De Wolf noted:

hz only really needs to be calculated once, so this line could be
moved up out of the loop, resulting in a likely unnoticeable
performance increase. :)
This commit is contained in:
Steve Schnepp 2013-02-27 08:22:39 +01:00
parent 7164a0e773
commit c7f80a0c4b
1 changed files with 1 additions and 1 deletions

View File

@ -136,8 +136,8 @@ int cpu(int argc, char **argv) {
}
if(!(f=fopen(PROC_STAT, "r")))
return fail("cannot open " PROC_STAT);
hz = getenvint("HZ", 100);
while(fgets(buff, 256, f)) {
hz = getenvint("HZ", 100);
if(!strncmp(buff, "cpu ", 4)) {
fclose(f);
if(!(s = strtok(buff+4, " \t")))