Changeset 17587 in josm for trunk


Ignore:
Timestamp:
2021-03-18T01:49:10+01:00 (4 years ago)
Author:
simon04
Message:

see #20613 - AbstractPrimitive.keySet/keys: fix fast path for single key

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r17584 r17587  
    650650            return Collections.emptySet();
    651651        }
    652         if (keys.length == 1) {
     652        if (keys.length == 2) {
    653653            return Collections.singleton(keys[0]);
    654654        }
     
    666666        if (k == null) {
    667667            return Stream.empty();
    668         } else if (k.length == 1) {
     668        } else if (k.length == 2) {
    669669            return Stream.of(k[0]);
    670670        } else {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java

    r17584 r17587  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotEquals;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    78
     
    1213
    1314import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     15
     16import java.util.Collections;
     17import java.util.HashSet;
    1418
    1519/**
     
    5054
    5155        testGetKey(n, "akey", "avalue");
     56        assertEquals(Collections.singleton("akey"), n.keySet());
     57        assertNotEquals(HashSet.class, n.keySet().getClass()); // expect Collections.singleton
     58
    5259    }
    5360
Note: See TracChangeset for help on using the changeset viewer.