bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17143: [PATCH] grep: speed-up for line matching in fgrep


From: Paolo Bonzini
Subject: bug#17143: [PATCH] grep: speed-up for line matching in fgrep
Date: Tue, 01 Apr 2014 10:45:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

Il 30/03/2014 14:14, Norihiro Tanaka ha scritto:
-          if (beg > buf && beg[-1] != eol)
-            continue;
-          if (beg + len < buf + size && beg[len] != eol)
-            continue;
-          goto success;
+          if (beg[-1] == eol && beg[len] == eol)
+            goto success;
+          beg = memchr (beg, eol, buf + size - beg);
         }

Are we sure that beg > buf && beg + len < buf + size?

Perhaps we need

  if (beg > buf && beg[-1] == eol &&
      beg + len < buf + size && beg[len] == eol)
    goto success;

  beg = memchr (beg, eol, buf + size - beg);

Otherwise, the patch is an obvious improvement.  Thanks!

Paolo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]