Sort suggested locations only once.

This commit is contained in:
Andreas Schildbach 2014-08-12 18:37:14 +02:00
parent 544fa018ca
commit cde4b9d0dc

View file

@ -20,6 +20,7 @@ package de.schildbach.pte.dto;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
@ -40,7 +41,8 @@ public final class SuggestLocationsResult implements Serializable
{ {
this.header = header; this.header = header;
this.status = Status.OK; this.status = Status.OK;
this.suggestedLocations = suggestedLocations; this.suggestedLocations = new LinkedList<SuggestedLocation>(suggestedLocations);
Collections.sort(this.suggestedLocations);
} }
public SuggestLocationsResult(final ResultHeader header, final Status status) public SuggestLocationsResult(final ResultHeader header, final Status status)
@ -62,8 +64,6 @@ public final class SuggestLocationsResult implements Serializable
public List<Location> getLocations() public List<Location> getLocations()
{ {
Collections.sort(suggestedLocations);
final List<Location> locations = new ArrayList<Location>(suggestedLocations.size()); final List<Location> locations = new ArrayList<Location>(suggestedLocations.size());
for (final SuggestedLocation location : suggestedLocations) for (final SuggestedLocation location : suggestedLocations)
locations.add(location.location); locations.add(location.location);