summaryrefslogtreecommitdiffstats
path: root/gettext-tools/libgrep
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-05-24 10:44:42 +0200
committerBruno Haible <bruno@clisp.org>2010-06-03 15:03:47 +0200
commit41d50d2ca8b6c81e418654921b04bf8cd9242813 (patch)
tree2643eafe69eb6947c96ae3df8db0906f554de05d /gettext-tools/libgrep
parent95551a9f64e25a9c469df8e7dfbf03b645c88f8f (diff)
downloadexternal_gettext-41d50d2ca8b6c81e418654921b04bf8cd9242813.zip
external_gettext-41d50d2ca8b6c81e418654921b04bf8cd9242813.tar.gz
external_gettext-41d50d2ca8b6c81e418654921b04bf8cd9242813.tar.bz2
Tiny optimization.
Diffstat (limited to 'gettext-tools/libgrep')
-rw-r--r--gettext-tools/libgrep/ChangeLog5
-rw-r--r--gettext-tools/libgrep/m-fgrep.c14
2 files changed, 12 insertions, 7 deletions
diff --git a/gettext-tools/libgrep/ChangeLog b/gettext-tools/libgrep/ChangeLog
index dd951db..8804b00 100644
--- a/gettext-tools/libgrep/ChangeLog
+++ b/gettext-tools/libgrep/ChangeLog
@@ -1,5 +1,10 @@
2010-05-24 Bruno Haible <bruno@clisp.org>
+ Tiny optimization.
+ * m-fgrep.c (Fexecute): New local variable buflim.
+
+2010-05-24 Bruno Haible <bruno@clisp.org>
+
* m-fgrep.c (Fcompile, Fexecute): Reduce scope of local variables.
* m-regex.c (compile, EGexecute): Likewise.
* kwset.c (kwsincr, treefails, kwsprep, bmexec, cwexec): Likewise.
diff --git a/gettext-tools/libgrep/m-fgrep.c b/gettext-tools/libgrep/m-fgrep.c
index 5c92365..7bb3715 100644
--- a/gettext-tools/libgrep/m-fgrep.c
+++ b/gettext-tools/libgrep/m-fgrep.c
@@ -157,6 +157,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
{
struct compiled_kwset *ckwset = (struct compiled_kwset *) compiled_pattern;
char eol = ckwset->eolbyte;
+ register const char *buflim = buf + buf_size;
register const char *beg;
register size_t len;
#ifdef MBS_SUPPORT
@@ -165,11 +166,10 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
mb_properties = check_multibyte_string (buf, buf_size);
#endif /* MBS_SUPPORT */
- for (beg = buf; beg <= buf + buf_size; ++beg)
+ for (beg = buf; beg <= buflim; ++beg)
{
struct kwsmatch kwsmatch;
- size_t offset =
- kwsexec (ckwset->kwset, beg, buf + buf_size - beg, &kwsmatch);
+ size_t offset = kwsexec (ckwset->kwset, beg, buflim - beg, &kwsmatch);
if (offset == (size_t) -1)
{
#ifdef MBS_SUPPORT
@@ -197,7 +197,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
{
if (beg > buf && beg[-1] != eol)
continue;
- if (beg + len < buf + buf_size && beg[len] != eol)
+ if (beg + len < buflim && beg[len] != eol)
continue;
goto success;
}
@@ -208,7 +208,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
{
if (curr > buf && IS_WORD_CONSTITUENT ((unsigned char) curr[-1]))
break;
- if (curr + len < buf + buf_size
+ if (curr + len < buflim
&& IS_WORD_CONSTITUENT ((unsigned char) curr[len]))
{
offset = kwsexec (ckwset->kwset, beg, --len, &kwsmatch);
@@ -241,11 +241,11 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
{
register const char *end;
- end = (const char *) memchr (beg + len, eol, (buf + buf_size) - (beg + len));
+ end = (const char *) memchr (beg + len, eol, buflim - (beg + len));
if (end != NULL)
end++;
else
- end = buf + buf_size;
+ end = buflim;
while (buf < beg && beg[-1] != eol)
--beg;
*match_size = end - beg;