1
1

painting: make use of the multidata of the preceding line

When painting a line, the multidata of the line /before/ it is valid
in most cases: it was determined just a moment ago.  And it tells us
all we need to know: whether there is an unpaired start match before
the current line or not.

The only exception is when painting the first line of the screen:
the multidata of the line before it might be stale.  So for the
first screen line we will always have to do some backtracking.
But that is left for later.

This fixes https://savannah.gnu.org/bugs/?50121.
Этот коммит содержится в:
Benno Schulenberg 2017-01-23 14:41:25 +01:00
родитель fb8fdcaa0a
Коммит b3bcc8eeac
2 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -370,6 +370,9 @@ void reset_multis(filestruct *fileptr, bool force)
}
}
refresh_needed = TRUE;
return;
/* If we got here, things have changed. */
reset_multis_for_id(fileptr, ink->id);

Просмотреть файл

@ -2420,6 +2420,22 @@ void edit_draw(filestruct *fileptr, const char *converted,
regmatch_t startmatch, endmatch;
/* The match positions of the start and end regexes. */
/* First check the multidata of the preceding line -- it tells
* us about the situation so far, and thus what to do here. */
if (start_line != NULL && start_line->multidata != NULL) {
if (start_line->multidata[varnish->id] == CWHOLELINE ||
start_line->multidata[varnish->id] == CENDAFTER) {
fileptr->multidata[varnish->id] = CNONE;
goto seek_an_end;
}
if (start_line->multidata[varnish->id] == CNONE ||
start_line->multidata[varnish->id] == CBEGINBEFORE ||
start_line->multidata[varnish->id] == CSTARTENDHERE) {
fileptr->multidata[varnish->id] = CNONE;
goto step_two;
}
}
/* First see if the multidata was maybe already calculated. */
if (fileptr->multidata[varnish->id] == CNONE)
goto tail_of_loop;
@ -2440,9 +2456,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* There is no precalculated multidata, or it is CENDAFTER or
* CSTARTENDHERE. In all cases, find out what to paint. */
/* When the multidata is unitialized, assume CNONE until one
* of the steps below concludes otherwise. */
if (fileptr->multidata[varnish->id] == -1)
/* Assume nothing gets painted until proven otherwise below. */
fileptr->multidata[varnish->id] = CNONE;
/* First check if the beginning of the line is colored by a
@ -2500,6 +2514,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
}
/* Indeed, there is a start without an end on that line. */
seek_an_end:
/* We've already checked that there is no end between the start
* and the current line. But is there an end after the start
* at all? We don't paint unterminated starts. */