@cryptotaxi247 / netdata-1 / commits / f8a46cf5e

minor optimizations and comments

Costa Tsaousis (ktsaou) committed Jan 13, 2017 at 00:21 UTC f8a46cf5e74a6b5c0e66e7d71402ff9453ac588e
1 file changed +7 -5
src/proc_net_dev.c
+7 -5
@@ -138,21 +138,23 @@ int do_proc_net_dev(int update_every, usec_t dt) {
138 }
139
140 ff = procfile_readall(ff);
141 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
141 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
142
143 uint32_t lines = procfile_lines(ff), l;
144 -
144 for(l = 2; l < lines ;l++) {
146 - uint32_t words = procfile_linewords(ff, l);
147 - if(words < 17) continue;
145 + // require 17 words on each line
146 + if(unlikely(procfile_linewords(ff, l) < 17)) continue;
147
148 struct netdev *d = get_netdev(procfile_lineword(ff, l, 0));
149
150 if(unlikely(!d->configured)) {
151 + // this is the first time we see this interface
152 +
153 + // remember we configured it
154 d->configured = 1;
155
156 + // start with the default enabled flag
157 d->enabled = enable_new_interfaces;
155 -
158 if(d->enabled) {
159 if(unlikely(!strcmp(d->name, "lo")))
160 d->enabled = CONFIG_ONDEMAND_NO;