Changeset 15024 in josm


Ignore:
Timestamp:
2019-04-27T12:33:28+02:00 (6 years ago)
Author:
GerdP
Message:

fix #17656: improve performance in MapCSSTagChecker
Don't put rules into index which should be ignored and have no other effect.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r14599 r15024  
    128128        final MapCSSRuleIndex multipolygonRules = new MapCSSRuleIndex();
    129129
    130         IndexData(MultiMap<String, TagCheck> checks) {
    131             buildIndex(checks);
    132         }
    133 
    134         private void buildIndex(MultiMap<String, TagCheck> checks) {
     130        private IndexData(MultiMap<String, TagCheck> checks, boolean includeOtherSeverity) {
     131            buildIndex(checks, includeOtherSeverity);
     132        }
     133
     134        private void buildIndex(MultiMap<String, TagCheck> checks, boolean includeOtherSeverity) {
    135135            List<TagCheck> allChecks = new ArrayList<>();
    136136            for (Set<TagCheck> cs : checks.values()) {
     
    147147            // optimization: filter rules for different primitive types
    148148            for (TagCheck c : allChecks) {
     149                if (!includeOtherSeverity && Severity.OTHER == c.getSeverity()
     150                        && c.setClassExpressions.isEmpty()) {
     151                    // Ignore "information" level checks if not wanted, unless they also set a MapCSS class
     152                    continue;
     153                }
     154
    149155                for (Selector s : c.rule.selectors) {
    150156                    // find the rightmost selector, this must be a GeneralSelector
     
    837843        final List<TestError> res = new ArrayList<>();
    838844        if (indexData == null)
    839             indexData = new IndexData(checks);
     845            indexData = new IndexData(checks, includeOtherSeverity);
    840846
    841847        MapCSSRuleIndex matchingRuleIndex = indexData.get(p);
     
    852858                TagCheck check = indexData.getCheck(r);
    853859                if (check != null) {
    854                     boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity;
    855                     // Do not run "information" level checks if not wanted, unless they also set a MapCSS class
    856                     if (ignoreError && check.setClassExpressions.isEmpty()) {
    857                         continue;
    858                     }
    859860                    if (r.declaration == lastDeclUsed)
    860861                        continue; // don't apply one declaration more than once
     
    862863
    863864                    r.declaration.execute(env);
    864                     if (!ignoreError && !check.errors.isEmpty()) {
     865                    if (!check.errors.isEmpty()) {
    865866                        final TestError error = check.getErrorForPrimitive(p, r.selector, env, new MapCSSTagCheckerAndRule(check.rule));
    866867                        if (error != null) {
     
    10951096        super.setShowElements(true);
    10961097        if (indexData == null) {
    1097             indexData = new IndexData(checks);
     1098            indexData = new IndexData(checks, ValidatorPrefHelper.PREF_OTHER.get());
    10981099        }
    10991100    }
Note: See TracChangeset for help on using the changeset viewer.