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:
parent
7164a0e773
commit
c7f80a0c4b
|
@ -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")))
|
||||
|
|
Loading…
Reference in New Issue