Unwrap if statements that are always true.

We're already checking whether rdp is null at the beginning. No need
to check this again and again.
This commit is contained in:
Karsten Loesing 2018-08-20 10:35:17 +02:00
parent 5e1ae90ec4
commit 5223617c6e
2 changed files with 140 additions and 150 deletions

View File

@ -90,7 +90,6 @@ public class ArchiveReader {
filesInInputDir.add(f);
}
} else {
if (rdp != null) {
try {
BufferedInputStream bis = null;
if (keepImportHistory
@ -135,14 +134,12 @@ public class ArchiveReader {
}
}
}
}
for (File pop : filesToRetry) {
/* TODO We need to parse microdescriptors ourselves, rather than
* RelayDescriptorParser, because only we know the valid-after
* time(s) of microdesc consensus(es) containing this
* microdescriptor. However, this breaks functional abstraction
* pretty badly. */
if (rdp != null) {
try {
BufferedInputStream bis = null;
if (pop.getName().endsWith(".bz2")) {
@ -239,7 +236,6 @@ public class ArchiveReader {
}
}
}
}
if (problems.isEmpty()) {
logger.debug("Finished importing files in directory "
+ archivesDirectory + "/.");

View File

@ -134,7 +134,6 @@ public class CachedRelayDescriptorReader {
/* Parse the cached consensus if we haven't parsed it before
* (but regardless of whether it's stale or not). */
if (rdp != null) {
String digest = Hex.encodeHexString(DigestUtils.sha1(
allData));
if (!lastImportHistory.contains(digest)
@ -144,7 +143,6 @@ public class CachedRelayDescriptorReader {
dumpStats.append(" (skipped)");
}
currentImportHistory.add(digest);
}
} else if (f.getName().equals("v3-status-votes")) {
int parsedNum = 0;
int skippedNum = 0;
@ -161,7 +159,6 @@ public class CachedRelayDescriptorReader {
byte[] rawNetworkStatusBytes = new byte[next - start];
System.arraycopy(allData, start, rawNetworkStatusBytes, 0,
next - start);
if (rdp != null) {
String digest = Hex.encodeHexString(DigestUtils.sha1(
rawNetworkStatusBytes));
if (!lastImportHistory.contains(digest)
@ -173,7 +170,6 @@ public class CachedRelayDescriptorReader {
}
currentImportHistory.add(digest);
}
}
start = next;
}
dumpStats.append("\n" + f.getName() + ": parsed " + parsedNum
@ -208,7 +204,6 @@ public class CachedRelayDescriptorReader {
end += endToken.length();
byte[] descBytes = new byte[end - start];
System.arraycopy(allData, start, descBytes, 0, end - start);
if (rdp != null) {
String digest = Hex.encodeHexString(DigestUtils.sha1(
descBytes));
if (!lastImportHistory.contains(digest)
@ -220,7 +215,6 @@ public class CachedRelayDescriptorReader {
}
currentImportHistory.add(digest);
}
}
dumpStats.append("\n" + f.getName() + ": parsed " + parsedNum
+ ", skipped " + skippedNum + " "
+ (f.getName().startsWith("cached-descriptors")