Ignore:
Timestamp:
2021-03-18T00:57:09+01:00 (4 years ago)
Author:
simon04
Message:

see #20613 - Use Tagged.visitKeys()

Avoids creating a temporary HashMap just for iteration purposes

File:
1 edited

Legend:

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

    r17434 r17585  
    1818import org.openstreetmap.josm.data.validation.TestError;
    1919import org.openstreetmap.josm.tools.Logging;
    20 import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2120
    2221/**
     
    224223    public List<TestError> validatePrimitive(OsmPrimitive p) {
    225224        final List<TestError> errors = new ArrayList<>();
    226         for (final String key : SubclassFilteredCollection.filter(p.keySet(),
    227                 Pattern.compile(":conditional(:.*)?$").asPredicate())) {
     225        final Pattern pattern = Pattern.compile(":conditional(:.*)?$");
     226        p.visitKeys((primitive, key, value) -> {
     227            if (!pattern.matcher(key).find()) {
     228                return;
     229            }
    228230            if (!isKeyValid(key)) {
    229231                errors.add(TestError.builder(this, Severity.WARNING, 3201)
     
    231233                        .primitives(p)
    232234                        .build());
    233                 continue;
    234             }
    235             final String value = p.get(key);
     235                return;
     236            }
    236237            final String error = validateValue(key, value);
    237238            if (error != null) {
     
    241242                        .build());
    242243            }
    243         }
     244        });
    244245        return errors;
    245246    }
Note: See TracChangeset for help on using the changeset viewer.