On Tue, Oct 30, 2018 at 2:46 PM Guillermo Rodriguez Garcia <guille.rodrig...@gmail.com> wrote: > > Thank you. > > One minor thing; in the code that has been commited, the seen_cached > and seen_available vars have been combined into one > (seen_cached_and_available). However the code now parses all lines in > /proc/meminfo twice until both Cached and MemAvailable have been > found: > > seen_cached_and_available = 2; > while (fgets(buf, sizeof(buf), fp)) { > if (sscanf(buf, "Cached: %lu %*s\n", cached_kb) == 1) > if (--seen_cached_and_available == 0) > break; > if (sscanf(buf, "MemAvailable: %lu %*s\n", available_kb) == 1) > if (--seen_cached_and_available == 0) > break; > } > > However the original code only checks for things it has not seen yet; > for example if it finds "Cached" then it will only check for > MemAvailable in the remaining lines: > > while (fgets(buf, sizeof(buf), f) != NULL && !(seen_cached && > seen_available)) { > if (!seen_cached && sscanf(buf, "Cached: %lu %*s\n", > cached_kb) == 1) { > seen_cached = 1; > } > else if (!seen_available && sscanf(buf, "MemAvailable: > %lu %*s\n", available_kb) == 1) { > seen_available = 1; > } > } > > I think it would be convenient to revert this change and keep the two > separate variables in order to avoid doing unnecessary work.
That's larger code. I don't think users of "free" are that performance-sensitive. _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox