[xerces-c] branch xerces-3.2 updated: DFAContentModel::checkUniqueParticleAttribution (): speed enhancement

[email protected]
Newsgroups gmane.text.xml.xerces-c.devel
Message-ID <166499650359.1081683.11808297429080203087@gitbox2-he-fi.apache.org>
This is an automated email from the ASF dual-hosted git repository.

scantor pushed a commit to branch xerces-3.2
in repository https://gitbox.apache.org/repos/asf/xerces-c.git


The following commit(s) were added to refs/heads/xerces-3.2 by this push:
     new decafd46e DFAContentModel::checkUniqueParticleAttribution (): speed enhancement
decafd46e is described below

commit decafd46e1473e976566008a6b689e58bcb44285
Author: Even Rouault <[email protected]>
AuthorDate: Mon Sep 20 11:59:45 2021 +0200

    DFAContentModel::checkUniqueParticleAttribution (): speed enhancement
    
    The complexity of this method is roughly O(n^3). Fuzzers can generate
    schemas with n = several thousands. The test fTransTable[i][j] == XMLContentModel::gInvalidTrans
    is independant of the k loop, and can thus being moved at a upper level
    to improve runtime.
---
 src/xercesc/validators/common/DFAContentModel.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/xercesc/validators/common/DFAContentModel.cpp b/src/xercesc/validators/common/DFAContentModel.cpp
index a6187ca59..05f2dcd3f 100644
--- a/src/xercesc/validators/common/DFAContentModel.cpp
+++ b/src/xercesc/validators/common/DFAContentModel.cpp
@@ -1642,9 +1642,10 @@ void DFAContentModel::checkUniqueParticleAttribution (SchemaGrammar*    const pG
     // for each state, check whether it has overlap transitions
     for (i = 0; i < fTransTableSize; i++) {
         for (j = 0; j < fElemMapSize; j++) {
+            if (fTransTable[i][j] == XMLContentModel::gInvalidTrans)
+                continue;
             for (k = j+1; k < fElemMapSize; k++) {
-                if (fTransTable[i][j] != XMLContentModel::gInvalidTrans &&
-                    fTransTable[i][k] != XMLContentModel::gInvalidTrans &&
+                if (fTransTable[i][k] != XMLContentModel::gInvalidTrans &&
                     conflictTable[j][k] == 0) {
 
                     // If this is text in a Schema mixed content model, skip it.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.