mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-28 00:21:53 +03:00
enhanced xmlRegStateAddTrans to check if transition is already present
* xmlregexp.c: enhanced xmlRegStateAddTrans to check if transition is already present and, if so, to ignore the request to add it. This has a very dramatic effect on memory requirements as well as efficiency. It also fixes bug 141762.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Mon May 10 15:49:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
|
||||||
|
|
||||||
|
* xmlregexp.c: enhanced xmlRegStateAddTrans to check if transition
|
||||||
|
is already present and, if so, to ignore the request to add it.
|
||||||
|
This has a very dramatic effect on memory requirements as well
|
||||||
|
as efficiency. It also fixes bug 141762.
|
||||||
|
|
||||||
Sun May 9 20:40:59 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
Sun May 9 20:40:59 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* Makefile.am python/tests/Makefile.am python/tests/tstLastError.py:
|
* Makefile.am python/tests/Makefile.am python/tests/tstLastError.py:
|
||||||
|
22
xmlregexp.c
22
xmlregexp.c
@ -1182,6 +1182,9 @@ static void
|
|||||||
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||||
xmlRegAtomPtr atom, xmlRegStatePtr target,
|
xmlRegAtomPtr atom, xmlRegStatePtr target,
|
||||||
int counter, int count) {
|
int counter, int count) {
|
||||||
|
|
||||||
|
int nrtrans;
|
||||||
|
|
||||||
if (state == NULL) {
|
if (state == NULL) {
|
||||||
ERROR("add state: state is NULL");
|
ERROR("add state: state is NULL");
|
||||||
return;
|
return;
|
||||||
@ -1190,6 +1193,25 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
|||||||
ERROR("add state: target is NULL");
|
ERROR("add state: target is NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Other routines follow the philosophy 'When in doubt, add a transition'
|
||||||
|
* so we check here whether such a transition is already present and, if
|
||||||
|
* so, silently ignore this request.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (nrtrans=0; nrtrans<state->nbTrans; nrtrans++) {
|
||||||
|
if ((state->trans[nrtrans].atom == atom) &&
|
||||||
|
(state->trans[nrtrans].to == target->no) &&
|
||||||
|
(state->trans[nrtrans].counter == counter) &&
|
||||||
|
(state->trans[nrtrans].count == count)) {
|
||||||
|
#ifdef DEBUG_REGEXP_GRAPH
|
||||||
|
printf("Ignoring duplicate transition from %d to %d\n",
|
||||||
|
state->no, target->no);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (state->maxTrans == 0) {
|
if (state->maxTrans == 0) {
|
||||||
state->maxTrans = 4;
|
state->maxTrans = 4;
|
||||||
state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans *
|
state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans *
|
||||||
|
Reference in New Issue
Block a user