Changeset 19107 in josm


Ignore:
Timestamp:
2024-06-17T15:25:41+02:00 (18 months ago)
Author:
taylor.smock
Message:

Replace most calls for getNodes in VectorWay with direct calls to underlying list

This is primarily to avoid new unmodifiable collection instantiations where we
don't need a copy of the list. This significantly reduces the cost of the
post-processing merge ways step. Specifically, there is a 55% drop in the memory
cost, and 90% fewer CPU cycles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/vector/VectorWay.java

    r18578 r19107  
    5757    @Override
    5858    public int getNodesCount() {
    59         return this.getNodes().size();
     59        return this.nodes.size();
    6060    }
    6161
    6262    @Override
    6363    public VectorNode getNode(int index) {
    64         return this.getNodes().get(index);
     64        return this.nodes.get(index);
    6565    }
    6666
     
    8383    @Override
    8484    public List<Long> getNodeIds() {
    85         return this.getNodes().stream().map(VectorNode::getId).collect(Collectors.toList());
     85        return this.nodes.stream().map(VectorNode::getId).collect(Collectors.toList());
    8686    }
    8787
    8888    @Override
    8989    public long getNodeId(int idx) {
    90         return this.getNodes().get(idx).getId();
     90        return this.nodes.get(idx).getId();
    9191    }
    9292
Note: See TracChangeset for help on using the changeset viewer.