diff --git a/src/ChangeLog b/src/ChangeLog index dcb37badf..e06d0dc15 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-06-27 Roland Illig + + * view.c (is_nroff_sequence): Reordered the statements to gain + a speed-off of 30 percent on a 10 MB file. + 2005-06-22 Pavel Tsekov * main.h: Export edit_one_file. diff --git a/src/view.c b/src/view.c index ef5b97f23..f522ce6de 100644 --- a/src/view.c +++ b/src/view.c @@ -781,16 +781,23 @@ view_ccache_dump (WView *view) static gboolean is_nroff_sequence (WView *view, offset_type offset) { - int c0, c1, c2, retval; + int c0, c1, c2; + + /* The following commands are ordered to speed up the calculation. */ + + c1 = get_byte_indexed (view, offset, 1); + if (c1 == -1 || c1 != '\b') + return FALSE; c0 = get_byte_indexed (view, offset, 0); - c1 = get_byte_indexed (view, offset, 1); - c2 = get_byte_indexed (view, offset, 2); + if (c0 == -1 || !is_printable(c0)) + return FALSE; - retval = (c0 != -1 && c1 != -1 && c2 != -1 - && is_printable (c0) && c1 == '\b' && is_printable (c2) - && (c0 == c2 || c0 == '_' || (c0 == '+' && c2 == 'o'))); - return retval; + c2 = get_byte_indexed (view, offset, 2); + if (c2 == -1 || !is_printable(c2)) + return FALSE; + + return (c0 == c2 || c0 == '_' || (c0 == '+' && c2 == 'o')); } /* Look up the missing components of ''coord'', which are given by