short bg;
int pair;
STAILQ_ENTRY(ColorLine) entries;
+
+ bool stop_matching : 1; ///< used by the pager for body patterns, to prevent the color from being retried once it fails
};
STAILQ_HEAD(ColorLineHead, ColorLine);
bool *force_redraw, bool q_classify)
{
struct ColorLine *color_line = NULL;
+ struct ColorLineHead *head = NULL;
regmatch_t pmatch[1];
bool found;
bool null_rx;
i = 0;
offset = 0;
line_info[n].chunks = 0;
+ if (line_info[n].type == MT_COLOR_HDEFAULT)
+ head = &ColorHdrList;
+ else
+ head = &ColorBodyList;
+ STAILQ_FOREACH(color_line, head, entries)
+ {
+ color_line->stop_matching = false;
+ }
do
{
if (!buf[offset])
found = false;
null_rx = false;
- struct ColorLineHead *head = NULL;
- if (line_info[n].type == MT_COLOR_HDEFAULT)
- head = &ColorHdrList;
- else
- head = &ColorBodyList;
STAILQ_FOREACH(color_line, head, entries)
{
- if (regexec(&color_line->regex, buf + offset, 1, pmatch,
- (offset ? REG_NOTBOL : 0)) == 0)
+ if (!color_line->stop_matching && regexec(&color_line->regex, buf + offset, 1, pmatch,
+ (offset ? REG_NOTBOL : 0)) == 0)
{
if (pmatch[0].rm_eo != pmatch[0].rm_so)
{
else
null_rx = true; /* empty regex; don't add it, but keep looking */
}
+ else
+ {
+ /* Once a regexp fails to match, don't try matching it again.
+ * On very long lines this can cause a performance issue if there
+ * are other regexps that have many matches. */
+ color_line->stop_matching = true;
+ }
}
if (null_rx)