Ticket #10391: 0002-Remove-right-selector-iteration-when-ELEMENT_OF.patch

File 0002-Remove-right-selector-iteration-when-ELEMENT_OF.patch, 3.7 KB (added by qeef, 6 years ago)

Remove right selector iteration when ELEMENT_OF

  • src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    From b47e141000bd61428d6f25dcedc751ef43ede3c9 Mon Sep 17 00:00:00 2001
    From: Jiri Hubacek <jiri.hubacek@gmail.com>
    Date: Sun, 23 Sep 2018 13:20:17 +0200
    Subject: [PATCH 2/2] Remove right selector iteration when ELEMENT_OF
    
    ---
     .../josm/gui/mappaint/mapcss/Selector.java         | 49 +---------------------
     1 file changed, 1 insertion(+), 48 deletions(-)
    
    diff --git src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
    index 3edcc7d95..8f6c9a7f3 100644
    public interface Selector {  
    339339            if (!right.matches(e))
    340340                return false;
    341341
    342             if (ChildOrParentSelectorType.ELEMENT_OF == type) {
    343 /*
    344                 if (e.osm instanceof INode || e.osm.getDataSet() == null) {
    345                     // nodes cannot contain elements
    346                     return false;
    347                 }
    348 
    349                 ContainsFinder containsFinder;
    350                 try {
    351                     // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon,
    352                     // use the multipolygon for further analysis
    353                     if (!(e.osm instanceof IWay)
    354                             || (right instanceof OptimizedGeneralSelector
    355                             && !((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION))) {
    356                         throw new NoSuchElementException();
    357                     }
    358                     final Collection<Relation> multipolygons = Utils.filteredCollection(SubclassFilteredCollection.filter(
    359                             e.osm.getReferrers(), p -> p.hasTag("type", "multipolygon")), Relation.class);
    360                     final Relation multipolygon = multipolygons.iterator().next();
    361                     if (multipolygon == null) throw new NoSuchElementException();
    362                     final Set<OsmPrimitive> members = multipolygon.getMemberPrimitives();
    363                     containsFinder = new ContainsFinder(new Environment(multipolygon)) {
    364                         @Override
    365                         public boolean isPrimitiveUsable(IPrimitive p) {
    366                             return super.isPrimitiveUsable(p) && !members.contains(p);
    367                         }
    368                     };
    369                 } catch (NoSuchElementException ignore) {
    370                     Logging.trace(ignore);
    371                     containsFinder = new ContainsFinder(e);
    372                 }
    373                 e.parent = e.osm;
    374 
    375                 if (left instanceof OptimizedGeneralSelector) {
    376                     if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) {
    377                         containsFinder.visit(e.osm.getDataSet().searchNodes(e.osm.getBBox()));
    378                     }
    379                     if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) {
    380                         containsFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox()));
    381                     }
    382                 } else {
    383                     // use slow test
    384                     containsFinder.visit(e.osm.getDataSet().allPrimitives());
    385                 }
    386 
    387                 return e.child != null;
    388 */
    389             } else if (ChildOrParentSelectorType.CROSSING == type && e.osm instanceof IWay) {
     342            if (ChildOrParentSelectorType.CROSSING == type && e.osm instanceof IWay) {
    390343                e.parent = e.osm;
    391344                final CrossingFinder crossingFinder = new CrossingFinder(e);
    392345                if (right instanceof OptimizedGeneralSelector