The existing dual-loop setup is unnecessary
as the outer loop only skips to the first non-zero value
and then exits once the inner loop completes.
Zero values in the inner loop have no affect on its logic.
Signed-off-by: Simon Horman <horms@verge.net.au>
[pushed declaration of subtotal out to function scope]
Signed-off-by: Ben Pfaff <blp@nicira.com>
enum { BUCKET_WIDTH = ROUND_UP(100, TIME_UPDATE_INTERVAL) };
enum { N_BUCKETS = 5000 / BUCKET_WIDTH };
int buckets[N_BUCKETS] = { 0 };
enum { BUCKET_WIDTH = ROUND_UP(100, TIME_UPDATE_INTERVAL) };
enum { N_BUCKETS = 5000 / BUCKET_WIDTH };
int buckets[N_BUCKETS] = { 0 };
+ int total, subtotal, bucket;
long long int now;
int i;
long long int now;
int i;
}
/* Find the first bucket whose flows should be expired. */
}
/* Find the first bucket whose flows should be expired. */
- for (bucket = 0; bucket < N_BUCKETS; bucket++) {
- if (buckets[bucket]) {
- int subtotal = 0;
- do {
- subtotal += buckets[bucket++];
- } while (bucket < N_BUCKETS && subtotal < MAX(1000, total / 100));
- break;
- }
- }
+ subtotal = bucket = 0;
+ do {
+ subtotal += buckets[bucket++];
+ } while (bucket < N_BUCKETS && subtotal < MAX(1000, total / 100));
if (VLOG_IS_DBG_ENABLED()) {
struct ds s;
if (VLOG_IS_DBG_ENABLED()) {
struct ds s;