fileio: let's minimize 'count' inc/dec calls

instead of increasing it and immediately after decreasing it again,
let's just increase it a bit later.
This commit is contained in:
Lennart Poettering 2018-12-17 11:52:05 +01:00
parent 41f11239c0
commit 91a306b813

View file

@ -746,11 +746,9 @@ int read_line_full(FILE *f, size_t limit, ReadLineFlags flags, char **ret) {
r = safe_fgetc(f, &c);
if (r < 0)
return r;
if (r == 0)
if (r == 0) /* EOF is definitely EOL */
break;
count++;
eol = categorize_eol(c, flags);
if (FLAGS_SET(previous_eol, EOL_ZERO) ||
@ -760,10 +758,11 @@ int read_line_full(FILE *f, size_t limit, ReadLineFlags flags, char **ret) {
* EOL marker has been seen right before? In either of these three cases we are
* done. But first, let's put this character back in the queue. */
assert_se(ungetc(c, f) != EOF);
count--;
break;
}
count++;
if (eol != EOL_NONE) {
previous_eol |= eol;
continue;