From 2a11bc0780b7b77c8871478e201ff11a8cff38cd Mon Sep 17 00:00:00 2001 From: "keith.paterson" Date: Thu, 12 Apr 2012 06:56:47 +0200 Subject: Small fix (where built more effectively) for Pull #1391 --- main/src/cgeo/geocaching/cgData.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index deeb459..d1b9e07 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -1884,11 +1884,11 @@ public class cgData { Cursor cursor = null; try { - StringBuilder where = new StringBuilder(); + StringBuilder where = null; // viewport limitation if (centerLat != null && centerLon != null && spanLat != null && spanLon != null) { - where.append(buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon)); + where = buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon); } else { @@ -1987,7 +1987,7 @@ public class cgData { * @return */ - private static String buildCoordinateWhere(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon) { + private static StringBuilder buildCoordinateWhere(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon) { StringBuilder where = new StringBuilder(); double latMin = (centerLat / 1e6) - ((spanLat / 1e6) / 2) - ((spanLat / 1e6) / 4); double latMax = (centerLat / 1e6) + ((spanLat / 1e6) / 2) + ((spanLat / 1e6) / 4); @@ -2015,7 +2015,7 @@ public class cgData { where.append(" and longitude <= "); where.append(String.format((Locale) null, "%.6f", lonMax)); where.append(')'); - return where.toString(); + return where; } /** @@ -2741,8 +2741,7 @@ public class cgData { Set geocodes = new HashSet(); // viewport limitation - StringBuilder where = new StringBuilder(); - where.append(buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon)); + StringBuilder where = buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon); // cacheType limitation if (cacheType != CacheType.ALL) { @@ -3463,8 +3462,7 @@ public class cgData { */ public Collection loadWaypoints(long centerLat, long centerLon, long spanLat, long spanLon) { - StringBuilder where = new StringBuilder(); - where.append(buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon)); + StringBuilder where = buildCoordinateWhere(centerLat, centerLon, spanLat, spanLon); init(); List waypoints = new ArrayList(); -- cgit v1.1