less: rearrange detection of non-regular files
authorRon Yorston <rmy@pobox.com>
Fri, 24 Jul 2015 13:28:08 +0000 (14:28 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 31 Jul 2015 14:22:07 +0000 (16:22 +0200)
commit70b84be9e85969491e542cecc3ae28fa7558a7ec
tree15b5b57b0dd60215e00e0d586ad744452b819026
parent159e032bf4cd24535e57daaf29a381b0d5163368
less: rearrange detection of non-regular files

Move the code to detect non-regular files to the point where the
file is being opened.  If num_lines == READING_FILE guarantees
that the file is regular.

Detect when a file becomes unreadable between it first being opened
and the call to update_num_lines.  Mark the file as being non-regular
so we don't try that again.

function                                             old     new   delta
reinitialize                                         197     245     +48
update_num_lines                                     159     127     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32)             Total: 16 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/less.c