From e95d9e93d99ce16d1a97826ddd51b4f1c0349a9f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 27 Mar 2004 09:11:25 +0000 Subject: [PATCH] (main): Rearrange filtering loop to be a tiny bit more efficient. --- src/du.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/du.c b/src/du.c index b9f38864fe..7ecaede1a6 100644 --- a/src/du.c +++ b/src/du.c @@ -773,23 +773,31 @@ main (int argc, char **argv) size_t i = 0; size_t j; - for (j = 0; (files[i] = files[j]); j++) - if (files[i][0]) - i++; - else - { - if (files_from) - { - /* Using the standard `filename:line-number:' prefix here is - not totally appropriate, since NUL is the separator, not NL, - but it might be better than nothing. */ - unsigned long int file_number = j + 1; - error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), - file_number, _("invalid zero-length file name")); - } - else - error (0, 0, "%s", _("invalid zero-length file name")); - } + for (j = 0; ; j++) + { + if (i != j) + files[i] = files[j]; + + if ( ! files[i]) + break; + + if (files[i][0]) + i++; + else + { + if (files_from) + { + /* Using the standard `filename:line-number:' prefix here is + not totally appropriate, since NUL is the separator, not NL, + but it might be better than nothing. */ + unsigned long int file_number = j + 1; + error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), + file_number, _("invalid zero-length file name")); + } + else + error (0, 0, "%s", _("invalid zero-length file name")); + } + } fail = (i != j); } -- 2.47.2