--- Begin Message ---
Subject: |
[PATCH 1/6] maint: mark a couple of static variables const |
Date: |
Tue, 7 Jun 2016 01:37:38 -0500 |
* src/dfa.c (parse_bracket_exp): mark zeroclass const.
* src/dfasearch.c: mark patterns0 const.
---
src/dfa.c | 2 +-
src/dfasearch.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index 4e47b39..19363ce 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1183,7 +1183,7 @@ parse_bracket_exp (void)
if (dfa->multibyte)
{
- static charclass zeroclass;
+ static charclass const zeroclass;
work_mbc->invert = invert;
work_mbc->cset = equal (ccl, zeroclass) ? -1 : charclass_index (ccl);
return MBCSET;
diff --git a/src/dfasearch.c b/src/dfasearch.c
index d3db824..8052ef0 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -38,7 +38,7 @@ static kwset_t kwset;
static struct dfa *dfa;
/* The Regex compiled patterns. */
-static struct patterns
+static const struct patterns
{
/* Regex compiled regexp. */
struct re_pattern_buffer regexbuf;
--
2.8.0.rc3
--- End Message ---
--- Begin Message ---
Subject: |
Re: [PATCH 1/6] maint: mark a couple of static variables const |
Date: |
Wed, 17 Aug 2016 18:54:05 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Thanks, this patch was installed into grep in June so I'm marking the bug report
as done.
Also, I installed the attached two patches as followup. The first is because
I've run into too many compilers that complain about 'static const int x;' on
the grounds that x should have an initializer. Rewriting the code to avoid these
zero constants makes the code a tiny bit smaller on x86-64, so it's likely a
tiny win anyway.
The 2nd patch changes this code to use 64-bit words on x86-64 GNU/Linux, much as
other parts of grep already do. This makes the code a tiny bit smaller too.
The runtime performance change is likely so small I haven't bothered to try to
measure it. Perhaps some day compilers will be smart enough to put those 256-bit
arrays into registers and regex nerds can tune it some more....
0001-dfa-avoid-uninitialized-constants.patch
Description: Text Data
0002-dfa-use-64-bit-when-ulong-is-at-least-that-wide.patch
Description: Text Data
--- End Message ---