[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep branch, master, updated. v2.10-51-g5036e6a
From: |
Paolo Bonzini |
Subject: |
grep branch, master, updated. v2.10-51-g5036e6a |
Date: |
Tue, 03 Jan 2012 13:09:31 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".
The branch, master has been updated
via 5036e6aedbe0dd4a3e9e0bcfcd2fd9ee88379244 (commit)
via 988961a3e00bf51bd8a0bc3d1c9736cc88e07e5e (commit)
via 3e13407d4cfcbac44a9a50a419a1d33ee2205788 (commit)
from 9f9829ffae8e4b9bd3370154209ae9c04b4c5208 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=5036e6aedbe0dd4a3e9e0bcfcd2fd9ee88379244
commit 5036e6aedbe0dd4a3e9e0bcfcd2fd9ee88379244
Author: Paolo Bonzini <address@hidden>
Date: Tue Jun 28 09:07:44 2011 +0200
dfa: automatically resize position_sets
* src/dfa.c (insert, copy, merge): Resize arrays here.
(dfaanalyze): Do not track number of allocated elements here.
(dfastate): Allocate mbps with only one element.
diff --git a/src/dfa.c b/src/dfa.c
index dfc108a..1261994 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1827,6 +1827,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
static void
copy (position_set const *src, position_set *dst)
{
+ REALLOC_IF_NECESSARY(dst->elems, dst->alloc, src->nelem);
memcpy(dst->elems, src->elems, sizeof(dst->elems[0]) * src->nelem);
dst->nelem = src->nelem;
}
@@ -1848,6 +1849,7 @@ insert (position p, position_set *s)
{
int count = s->nelem;
int lo = 0, hi = count;
+ int i;
while (lo < hi)
{
int mid = ((unsigned) lo + (unsigned) hi) >> 1;
@@ -1858,15 +1860,16 @@ insert (position p, position_set *s)
}
if (lo < count && p.index == s->elems[lo].index)
- s->elems[lo].constraint |= p.constraint;
- else
{
- int i;
- for (i = count; i > lo; i--)
- s->elems[i] = s->elems[i - 1];
- s->elems[lo] = p;
- ++s->nelem;
+ s->elems[lo].constraint |= p.constraint;
+ return;
}
+
+ REALLOC_IF_NECESSARY(s->elems, s->alloc, count + 1);
+ for (i = count; i > lo; i--)
+ s->elems[i] = s->elems[i - 1];
+ s->elems[lo] = p;
+ ++s->nelem;
}
/* Merge two sets of positions into a third. The result is exactly as if
@@ -1876,6 +1879,7 @@ merge (position_set const *s1, position_set const *s2,
position_set *m)
{
int i = 0, j = 0;
+ REALLOC_IF_NECESSARY(m->elems, m->alloc, s1->nelem + s2->nelem);
m->nelem = 0;
while (i < s1->nelem && j < s2->nelem)
if (s1->elems[i].index > s2->elems[j].index)
@@ -2161,8 +2165,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-1]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2181,8 +2183,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-2]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2290,8 +2290,6 @@ dfaanalyze (struct dfa *d, int searchflag)
#endif
copy(&d->follows[i], &merged);
epsclosure(&merged, d);
- REALLOC_IF_NECESSARY(d->follows[i].elems, d->follows[i].alloc,
- merged.nelem);
copy(&merged, &d->follows[i]);
}
@@ -2409,7 +2407,7 @@ dfastate (int s, struct dfa *d, int trans[])
must put it to d->states[s].mbps, which contains the positions
which can match with a single character not a byte. */
if (d->states[s].mbps.nelem == 0)
- alloc_position_set(&d->states[s].mbps, d->states[s].elems.nelem);
+ alloc_position_set(&d->states[s].mbps, 1);
insert(pos, &(d->states[s].mbps));
continue;
}
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=988961a3e00bf51bd8a0bc3d1c9736cc88e07e5e
commit 5036e6aedbe0dd4a3e9e0bcfcd2fd9ee88379244
Author: Paolo Bonzini <address@hidden>
Date: Tue Jun 28 09:07:44 2011 +0200
dfa: automatically resize position_sets
* src/dfa.c (insert, copy, merge): Resize arrays here.
(dfaanalyze): Do not track number of allocated elements here.
(dfastate): Allocate mbps with only one element.
diff --git a/src/dfa.c b/src/dfa.c
index dfc108a..1261994 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1827,6 +1827,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
static void
copy (position_set const *src, position_set *dst)
{
+ REALLOC_IF_NECESSARY(dst->elems, dst->alloc, src->nelem);
memcpy(dst->elems, src->elems, sizeof(dst->elems[0]) * src->nelem);
dst->nelem = src->nelem;
}
@@ -1848,6 +1849,7 @@ insert (position p, position_set *s)
{
int count = s->nelem;
int lo = 0, hi = count;
+ int i;
while (lo < hi)
{
int mid = ((unsigned) lo + (unsigned) hi) >> 1;
@@ -1858,15 +1860,16 @@ insert (position p, position_set *s)
}
if (lo < count && p.index == s->elems[lo].index)
- s->elems[lo].constraint |= p.constraint;
- else
{
- int i;
- for (i = count; i > lo; i--)
- s->elems[i] = s->elems[i - 1];
- s->elems[lo] = p;
- ++s->nelem;
+ s->elems[lo].constraint |= p.constraint;
+ return;
}
+
+ REALLOC_IF_NECESSARY(s->elems, s->alloc, count + 1);
+ for (i = count; i > lo; i--)
+ s->elems[i] = s->elems[i - 1];
+ s->elems[lo] = p;
+ ++s->nelem;
}
/* Merge two sets of positions into a third. The result is exactly as if
@@ -1876,6 +1879,7 @@ merge (position_set const *s1, position_set const *s2,
position_set *m)
{
int i = 0, j = 0;
+ REALLOC_IF_NECESSARY(m->elems, m->alloc, s1->nelem + s2->nelem);
m->nelem = 0;
while (i < s1->nelem && j < s2->nelem)
if (s1->elems[i].index > s2->elems[j].index)
@@ -2161,8 +2165,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-1]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2181,8 +2183,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-2]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2290,8 +2290,6 @@ dfaanalyze (struct dfa *d, int searchflag)
#endif
copy(&d->follows[i], &merged);
epsclosure(&merged, d);
- REALLOC_IF_NECESSARY(d->follows[i].elems, d->follows[i].alloc,
- merged.nelem);
copy(&merged, &d->follows[i]);
}
@@ -2409,7 +2407,7 @@ dfastate (int s, struct dfa *d, int trans[])
must put it to d->states[s].mbps, which contains the positions
which can match with a single character not a byte. */
if (d->states[s].mbps.nelem == 0)
- alloc_position_set(&d->states[s].mbps, d->states[s].elems.nelem);
+ alloc_position_set(&d->states[s].mbps, 1);
insert(pos, &(d->states[s].mbps));
continue;
}
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=3e13407d4cfcbac44a9a50a419a1d33ee2205788
commit 5036e6aedbe0dd4a3e9e0bcfcd2fd9ee88379244
Author: Paolo Bonzini <address@hidden>
Date: Tue Jun 28 09:07:44 2011 +0200
dfa: automatically resize position_sets
* src/dfa.c (insert, copy, merge): Resize arrays here.
(dfaanalyze): Do not track number of allocated elements here.
(dfastate): Allocate mbps with only one element.
diff --git a/src/dfa.c b/src/dfa.c
index dfc108a..1261994 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1827,6 +1827,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
static void
copy (position_set const *src, position_set *dst)
{
+ REALLOC_IF_NECESSARY(dst->elems, dst->alloc, src->nelem);
memcpy(dst->elems, src->elems, sizeof(dst->elems[0]) * src->nelem);
dst->nelem = src->nelem;
}
@@ -1848,6 +1849,7 @@ insert (position p, position_set *s)
{
int count = s->nelem;
int lo = 0, hi = count;
+ int i;
while (lo < hi)
{
int mid = ((unsigned) lo + (unsigned) hi) >> 1;
@@ -1858,15 +1860,16 @@ insert (position p, position_set *s)
}
if (lo < count && p.index == s->elems[lo].index)
- s->elems[lo].constraint |= p.constraint;
- else
{
- int i;
- for (i = count; i > lo; i--)
- s->elems[i] = s->elems[i - 1];
- s->elems[lo] = p;
- ++s->nelem;
+ s->elems[lo].constraint |= p.constraint;
+ return;
}
+
+ REALLOC_IF_NECESSARY(s->elems, s->alloc, count + 1);
+ for (i = count; i > lo; i--)
+ s->elems[i] = s->elems[i - 1];
+ s->elems[lo] = p;
+ ++s->nelem;
}
/* Merge two sets of positions into a third. The result is exactly as if
@@ -1876,6 +1879,7 @@ merge (position_set const *s1, position_set const *s2,
position_set *m)
{
int i = 0, j = 0;
+ REALLOC_IF_NECESSARY(m->elems, m->alloc, s1->nelem + s2->nelem);
m->nelem = 0;
while (i < s1->nelem && j < s2->nelem)
if (s1->elems[i].index > s2->elems[j].index)
@@ -2161,8 +2165,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-1]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2181,8 +2183,6 @@ dfaanalyze (struct dfa *d, int searchflag)
for (j = 0; j < nlastpos[-2]; ++j)
{
merge(&tmp, &d->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems,
- d->follows[pos[j].index].alloc, merged.nelem);
copy(&merged, &d->follows[pos[j].index]);
}
@@ -2290,8 +2290,6 @@ dfaanalyze (struct dfa *d, int searchflag)
#endif
copy(&d->follows[i], &merged);
epsclosure(&merged, d);
- REALLOC_IF_NECESSARY(d->follows[i].elems, d->follows[i].alloc,
- merged.nelem);
copy(&merged, &d->follows[i]);
}
@@ -2409,7 +2407,7 @@ dfastate (int s, struct dfa *d, int trans[])
must put it to d->states[s].mbps, which contains the positions
which can match with a single character not a byte. */
if (d->states[s].mbps.nelem == 0)
- alloc_position_set(&d->states[s].mbps, d->states[s].elems.nelem);
+ alloc_position_set(&d->states[s].mbps, 1);
insert(pos, &(d->states[s].mbps));
continue;
}
-----------------------------------------------------------------------
Summary of changes:
src/dfa.c | 35 +++++++++++++++--------------------
1 files changed, 15 insertions(+), 20 deletions(-)
hooks/post-receive
--
grep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep branch, master, updated. v2.10-51-g5036e6a,
Paolo Bonzini <=