[PATCH] Speedup of node drawing
|Reported by:||bilbo||Owned by:||team|
1) org.openstreetmap.josm.data.osm.Node.isConnectionNode() is relatively expensive (get list of referrers, then filter it for ways, then check size of list) and takes for about 14% of CPU time spent in org.openstreetmap.josm.gui.mappaint.SimpleNodeElemStyle.paintPrimitive().
I added isReferredByWays(N) to OSMPrimitive which merely checks for being referred by N or more ways and it is faster (no list is created and filtered, only number of referred Ways is counted and compared)
Also, this still relatively expensive function is called 3 times during painting. I modified the code to call it only once and store the result.
2) org.openstreetmap.josm.data.osm.Node.getEastNorth() is called 4 times during painting, eating 12% of CPU time instead of 3% needed in case of single call and storing the value for further comparisons
3) Some minor changes, like calculating size AFTER checking whether to paint the node at all...
This patch should improve time needed to repaint nodes by about 15% to 20%. While it is faster, it is still pretty slow .... moving "map" with just 420000 untagged nodes on core i7 is very choppy with about only 3 redraws per second.
Ideas for further improvement:
Store number of ways and relations referring primitive, then just read the counter (speedup, but at cost of having extra 2 ints per primitive) - maybe there is other code that would benefit from this? Some code that merely needs to know whether a node/way is part of another way/relation without needing to know the list?
It is not necessary to check in MapPainter.drawNode/drawNodeIcon whether node lies within boundaries - this is done already in MapPaintVisitor.drawNode, but is it possible to paint nodes somewhere else? Perhaps the check is useless and it can go away.