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

Previous Next

Package: grep;

Reported by: Norihiro Tanaka <noritnk <at> kcn.ne.jp>

Date: Sun, 30 Mar 2014 12:15:03 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paolo Bonzini <bonzini <at> gnu.org>
To: Norihiro Tanaka <noritnk <at> kcn.ne.jp>, 17143 <at> debbugs.gnu.org
Subject: bug#17143: [PATCH] grep: speed-up for line matching in fgrep
Date: Tue, 01 Apr 2014 10:45:12 +0200
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




This bug report was last modified 11 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.