mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 18:55:40 +03:00
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:
parent
41f11239c0
commit
91a306b813
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user