From 4c90f4aef38d9c08f5f75cb46e28e4192b93d61b Mon Sep 17 00:00:00 2001 From: "Nelson A. de Oliveira" Date: Fri, 2 Aug 2013 21:21:30 -0300 Subject: [PATCH] Replace StringBuffer.toString() in concatenation In addition to being confusing, this code performs String allocation and copying, which is unnecessary as of JDK1.4 --- .../src/net/osmand/plus/activities/LiveMonitoringHelper.java | 2 +- .../plus/activities/search/SearchAddressOnlineFragment.java | 2 +- .../net/osmand/plus/activities/search/SearchPOIActivity.java | 4 ++-- .../plus/activities/search/SearchTransportFragment.java | 2 +- OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java | 2 +- OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java | 4 ++-- OsmAnd/src/net/osmand/plus/routing/RouteProvider.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java b/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java index 76e09aed50..6efba25a22 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java @@ -166,7 +166,7 @@ public class LiveMonitoringHelper { is.close(); } httpclient.getConnectionManager().shutdown(); - log.info("Montior response : " + responseBody.toString()); + log.info("Montior response : " + responseBody); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java index 1b5bb0154d..8ed4783e84 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java @@ -161,7 +161,7 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea b.append("?format=xml&addressdetails=0&accept-language=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$ b.append("&q=").append(URLEncoder.encode(search, "UTF-8")); //$NON-NLS-1$ - log.info("Searching address at : " + b.toString()); //$NON-NLS-1$ + log.info("Searching address at : " + b); //$NON-NLS-1$ URL url = new URL(b.toString()); URLConnection conn = url.openConnection(); conn.setDoInput(true); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index d927b1fe43..a0ca2d758e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -811,8 +811,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa StringBuilder value = new StringBuilder(); MapRenderingTypes.getDefault().getAmenityTagValue(amenity.getType(), amenity.getSubType(), tag, value); - if(RenderingIcons.containsBigIcon(tag.toString() + "_" + value.toString())) { - icon.setImageResource(RenderingIcons.getBigIconResourceId(tag.toString() + "_" + value.toString())); + if(RenderingIcons.containsBigIcon(tag + "_" + value)) { + icon.setImageResource(RenderingIcons.getBigIconResourceId(tag + "_" + value)); } else if(RenderingIcons.containsBigIcon(value.toString())) { icon.setImageResource(RenderingIcons.getBigIconResourceId(value.toString())); } else { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java index 1adca19e4f..332d6674b6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java @@ -505,7 +505,7 @@ public class SearchTransportFragment extends SherlockFragment implements SearchA int dist = locationToStart == null ? 0 : (int) (MapUtils.getDistance(stop.getStart().getLocation(), locationToStart)); String distance = OsmAndFormatter.getFormattedDistance(dist, (ClientContext) getApplication()) + " "; //$NON-NLS-1$ - label.setText(distance + labelW.toString(), TextView.BufferType.SPANNABLE); + label.setText(distance + labelW, TextView.BufferType.SPANNABLE); ((Spannable) label.getText()).setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1, 0); return (row); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index b7a607847b..f199263a46 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -289,7 +289,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider b.append(",").append(rightLongitude); //$NON-NLS-1$ b.append(",").append(topLatitude); //$NON-NLS-1$ try { - log.info("Loading bugs " + b.toString()); //$NON-NLS-1$ + log.info("Loading bugs " + b); //$NON-NLS-1$ URL url = new URL(b.toString()); URLConnection connection = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java index b93055a249..bfd34b9b58 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java @@ -107,11 +107,11 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil { responseBody.append(s); } } - log.info("Response : " + responseBody.toString()); //$NON-NLS-1$ + log.info("Response : " + responseBody); //$NON-NLS-1$ } connection.disconnect(); if (!ok) { - return msg + "\n" + responseBody.toString(); + return msg + "\n" + responseBody; } } catch (NullPointerException e) { // that's tricky case why NPE is thrown to fix that problem httpClient could be used diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 702282637a..68a296776b 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -630,7 +630,7 @@ public class RouteProvider { // TODO if we would get instructions from the service, we could use this language setting // .append("&language=").append(Locale.getDefault().getLanguage()); - log.info("URL route " + request.toString()); + log.info("URL route " + request); URI uri = URI.create(request.toString()); URL url = uri.toURL(); URLConnection connection = url.openConnection();