Changeset 18451 in josm for trunk/src


Ignore:
Timestamp:
2022-05-16T22:24:59+02:00 (4 years ago)
Author:
taylor.smock
Message:

Fix #22073: Optimized regexes (string starts with, ends with, contains) do not work

This was caused by taking a portion of a regex (for example, _name from
/_name$/), and using that to match against keys. So alt_name would not
match, but _name would. All regex patterns should now be added to the
remaining field in MapCSSRuleIndex, and there now exists a test to ensure
we do not forget to add new non-regex types to the valid key type list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRuleIndex.java

    r18208 r18451  
    55import java.util.BitSet;
    66import java.util.Collections;
     7import java.util.EnumSet;
    78import java.util.HashMap;
    89import java.util.Iterator;
     
    121122    }
    122123
     124    /** Valid key types for indexing (see {@link ConditionFactory.KeyMatchType}) */
     125    private static final EnumSet<ConditionFactory.KeyMatchType> VALID_INDEX_KEY_TYPES = EnumSet.of(
     126            ConditionFactory.KeyMatchType.EQ, ConditionFactory.KeyMatchType.TRUE, ConditionFactory.KeyMatchType.FALSE);
     127
    123128    /**
    124129     * All rules this index is for. Once this index is built, this list is sorted.
     
    187192        String key = null;
    188193        for (Condition c : conds) {
    189             if (c instanceof KeyCondition) {
     194            if (c instanceof KeyCondition && VALID_INDEX_KEY_TYPES.contains(((KeyCondition) c).matchType)) {
    190195                KeyCondition keyCondition = (KeyCondition) c;
    191196                if (!keyCondition.negateResult) {
Note: See TracChangeset for help on using the changeset viewer.