diff options
author | raveit65 <[email protected]> | 2020-08-30 18:04:32 +0200 |
---|---|---|
committer | Luke from DC <[email protected]> | 2020-08-30 18:13:21 +0000 |
commit | 19cf719782152bba59cd8e4442dcfdeaa3daf75a (patch) | |
tree | 227987aff1f2cdd7d806b8ccf25a36040d8a9dae /multiload/autoscaler.c | |
parent | ca0e34a0c7920cfe18f68101597db6c0c9e13a85 (diff) | |
download | mate-applets-19cf719782152bba59cd8e4442dcfdeaa3daf75a.tar.bz2 mate-applets-19cf719782152bba59cd8e4442dcfdeaa3daf75a.tar.xz |
multiload: improve code-style
- tab to spaces
- fix some indents
Diffstat (limited to 'multiload/autoscaler.c')
-rw-r--r-- | multiload/autoscaler.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/multiload/autoscaler.c b/multiload/autoscaler.c index 39eab7db..735b2713 100644 --- a/multiload/autoscaler.c +++ b/multiload/autoscaler.c @@ -6,46 +6,46 @@ /* i wish i could have used C99 initializers instead of writing this function */ void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor) { - that->update_interval = interval; - that->floor = floor; - that->max = 0; - that->count = 0; - that->last_update = 0; - that->sum = 0.0f; - that->last_average = 0.0f; + that->update_interval = interval; + that->floor = floor; + that->max = 0; + that->count = 0; + that->last_update = 0; + that->sum = 0.0f; + that->last_average = 0.0f; } unsigned autoscaler_get_max(AutoScaler *that, unsigned current) { - time_t now; + time_t now; - that->sum += current; - that->count++; - time(&now); + that->sum += current; + that->count++; + time(&now); - if((float)difftime(now, that->last_update) > that->update_interval) - { - float new_average = that->sum / that->count; - float average; + if((float)difftime(now, that->last_update) > that->update_interval) + { + float new_average = that->sum / that->count; + float average; - if(new_average < that->last_average) - average = ((that->last_average * 0.5f) + new_average) / 1.5f; - else - average = new_average; + if(new_average < that->last_average) + average = ((that->last_average * 0.5f) + new_average) / 1.5f; + else + average = new_average; - that->max = average * 1.2f; + that->max = average * 1.2f; - that->sum = 0.0f; - that->count = 0; - that->last_update = now; - that->last_average = average; - } + that->sum = 0.0f; + that->count = 0; + that->last_update = now; + that->last_average = average; + } - that->max = MAX(that->max, current); - that->max = MAX(that->max, that->floor); + that->max = MAX(that->max, current); + that->max = MAX(that->max, that->floor); #if 0 - printf("%p max = %u, current = %u, last_average = %f\n", that, that->max, current, that->last_average); + printf("%p max = %u, current = %u, last_average = %f\n", that, that->max, current, that->last_average); #endif - return that->max; + return that->max; } |