[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] Avoid unnecessary conversions to String.
commit 09765ef24569d72666843440ae2a7225c2b38ac5
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed Nov 20 12:17:56 2019 +0100
Avoid unnecessary conversions to String.
---
.../java/org/torproject/metrics/onionoo/docs/BandwidthStatus.java | 4 ++--
src/main/java/org/torproject/metrics/onionoo/docs/NodeStatus.java | 4 ++--
.../java/org/torproject/metrics/onionoo/updater/DescriptorQueue.java | 3 +--
.../java/org/torproject/metrics/onionoo/updater/LookupService.java | 2 +-
.../org/torproject/metrics/onionoo/server/ResourceServletTest.java | 4 ++--
5 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/onionoo/docs/BandwidthStatus.java b/src/main/java/org/torproject/metrics/onionoo/docs/BandwidthStatus.java
index 6466b63..c9eddf1 100644
--- a/src/main/java/org/torproject/metrics/onionoo/docs/BandwidthStatus.java
+++ b/src/main/java/org/torproject/metrics/onionoo/docs/BandwidthStatus.java
@@ -173,12 +173,12 @@ public class BandwidthStatus extends Document {
for (long[] v : writeHistory.values()) {
sb.append("w ").append(DateTimeHelper.format(v[0])).append(" ")
.append(DateTimeHelper.format(v[1])).append(" ")
- .append(String.valueOf(v[2])).append("\n");
+ .append(v[2]).append("\n");
}
for (long[] v : readHistory.values()) {
sb.append("r ").append(DateTimeHelper.format(v[0])).append(" ")
.append(DateTimeHelper.format(v[1])).append(" ")
- .append(String.valueOf(v[2])).append("\n");
+ .append(v[2]).append("\n");
}
return sb.toString();
}
diff --git a/src/main/java/org/torproject/metrics/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/metrics/onionoo/docs/NodeStatus.java
index 826db9e..1294bd5 100644
--- a/src/main/java/org/torproject/metrics/onionoo/docs/NodeStatus.java
+++ b/src/main/java/org/torproject/metrics/onionoo/docs/NodeStatus.java
@@ -724,11 +724,11 @@ public class NodeStatus extends Document {
sb.append("\t").append(this.dirPort).append("\t");
sb.append(StringUtils.join(this.getRelayFlags(), ","));
if (this.isRelay) {
- sb.append("\t").append(String.valueOf(this.consensusWeight));
+ sb.append("\t").append(this.consensusWeight);
sb.append("\t")
.append((this.countryCode != null ? this.countryCode : "??"));
sb.append("\t"); /* formerly used for storing host names */
- sb.append("\t").append(String.valueOf(this.lastRdnsLookup));
+ sb.append("\t").append(this.lastRdnsLookup);
sb.append("\t").append((this.defaultPolicy != null
? this.defaultPolicy : "null"));
sb.append("\t").append((this.portList != null ? this.portList : "null"));
diff --git a/src/main/java/org/torproject/metrics/onionoo/updater/DescriptorQueue.java b/src/main/java/org/torproject/metrics/onionoo/updater/DescriptorQueue.java
index 6cae37e..c609b2a 100644
--- a/src/main/java/org/torproject/metrics/onionoo/updater/DescriptorQueue.java
+++ b/src/main/java/org/torproject/metrics/onionoo/updater/DescriptorQueue.java
@@ -124,8 +124,7 @@ class DescriptorQueue {
for (Map.Entry<String, Long> e : excludedAndParsedFiles.entrySet()) {
String absolutePath = e.getKey();
long lastModifiedMillis = e.getValue();
- bw.write(String.valueOf(lastModifiedMillis) + " " + absolutePath
- + "\n");
+ bw.write(lastModifiedMillis + " " + absolutePath + "\n");
}
} catch (IOException e) {
log.error("Could not write history file '{}'. Not excluding descriptors "
diff --git a/src/main/java/org/torproject/metrics/onionoo/updater/LookupService.java b/src/main/java/org/torproject/metrics/onionoo/updater/LookupService.java
index 947c78c..63fcaa8 100644
--- a/src/main/java/org/torproject/metrics/onionoo/updater/LookupService.java
+++ b/src/main/java/org/torproject/metrics/onionoo/updater/LookupService.java
@@ -248,7 +248,7 @@ public class LookupService {
this.geoLite2AsnBlocksIpv4CsvFile.getAbsolutePath());
return lookupResults;
}
- String asNumber = "AS" + String.valueOf(Integer.parseInt(parts[1]));
+ String asNumber = "AS" + Integer.parseInt(parts[1]);
String asName = parts[2];
while (firstAddressNumber < startIpNum
&& firstAddressNumber != -1L) {
diff --git a/src/test/java/org/torproject/metrics/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/metrics/onionoo/server/ResourceServletTest.java
index 7df56ea..9224620 100644
--- a/src/test/java/org/torproject/metrics/onionoo/server/ResourceServletTest.java
+++ b/src/test/java/org/torproject/metrics/onionoo/server/ResourceServletTest.java
@@ -1358,7 +1358,7 @@ public class ResourceServletTest {
@Test(timeout = 100)
public void testFirstSeenDaysMaxInt() {
this.assertSummaryDocument(
- "/summary?last_seen_days=" + String.valueOf(Integer.MAX_VALUE), 0,
+ "/summary?last_seen_days=" + Integer.MAX_VALUE, 0,
null, 0, null);
}
@@ -1366,7 +1366,7 @@ public class ResourceServletTest {
public void testFirstSeenDaysMaxIntPlusOne() {
this.assertErrorStatusCode(
"/summary?first_seen_days="
- + String.valueOf(((long) Integer.MAX_VALUE) + 1L), 400);
+ + (((long) Integer.MAX_VALUE) + 1L), 400);
}
@Test(timeout = 100)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits