commit 8c1bdd9a8403a0a19149b6388bbc940ee632eaae Author: Karsten Loesing karsten.loesing@gmx.net Date: Sat Mar 17 10:45:55 2018 +0100
Avoid calling bytesFor() unnecessarily.
Found while looking into #25522. --- src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java b/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java index df178b4..fd301b0 100644 --- a/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java +++ b/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java @@ -169,9 +169,12 @@ public class SanitizeWeblogs extends CollecTorMain { OutputStream os = FileType.XZ.outputStream(baos)) { for (Map.Entry<String, Long> entry : lines.entrySet()) { long count = entry.getValue(); - byte[] batch = bytesFor(entry.getKey(), BATCH); + byte[] batch = null; while (count > 0) { if (count > BATCH) { + if (null == batch) { + batch = bytesFor(entry.getKey(), BATCH); + } os.write(batch); count -= BATCH; } else {
tor-commits@lists.torproject.org