From 901827458f14156b9df036f171595f1a1754a636 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:20:30 -0500 Subject: [PATCH] Performance: 'List.remove()' called in loop --- .../java/net/osmand/router/TransportStopsRouteReader.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TransportStopsRouteReader.java b/OsmAnd-java/src/main/java/net/osmand/router/TransportStopsRouteReader.java index 7428196332..13da3748bb 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TransportStopsRouteReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TransportStopsRouteReader.java @@ -325,9 +325,7 @@ public class TransportStopsRouteReader { // merge first part if (commonStopFirst < commonStopSecond || (commonStopFirst == commonStopSecond && firstSegment.get(0).isMissingStop())) { - for (int i = 0; i <= commonStopFirst; i++) { - firstSegment.remove(0); - } + firstSegment.subList(0, commonStopFirst + 1).clear(); for (int i = commonStopSecond; i >= 0; i--) { firstSegment.add(0, segmentToMerge.get(i)); }