From 6a40e12124b2d441a1085a4e486d685ed12665d0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 4 May 2019 19:32:52 -0500 Subject: Optimize regexec0() for long lines. Don't strlen() to find NUL to skip to until after we've confirmed first section hasn't got a match (by calling regexec() on it). --- lib/lib.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index 7b7d84d6..6df9566c 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -1327,16 +1327,9 @@ int regexec0(regex_t *preg, char *string, long len, int nmatch, char *s = string; for (;;) { - long ll = 0; - int rc; + int rc = regexec(preg, s, nmatch, pmatch, eflags); - while (len && !*s) { - s++; - len--; - } - while (s[ll] && ll