Code cleanups

This commit is contained in:
Goooler
2021-08-27 01:00:37 +08:00
parent 2cbefeb91d
commit 94ed86db28
47 changed files with 266 additions and 308 deletions

View File

@ -41,8 +41,8 @@ public class BrutIO {
public static long recursiveModifiedTime(File[] files) {
long modified = 0;
for (int i = 0; i < files.length; i++) {
long submodified = recursiveModifiedTime(files[i]);
for (File file : files) {
long submodified = recursiveModifiedTime(file);
if (submodified > modified) {
modified = submodified;
}
@ -54,8 +54,8 @@ public class BrutIO {
long modified = file.lastModified();
if (file.isDirectory()) {
File[] subfiles = file.listFiles();
for (int i = 0; i < subfiles.length; i++) {
long submodified = recursiveModifiedTime(subfiles[i]);
for (File subfile : subfiles) {
long submodified = recursiveModifiedTime(subfile);
if (submodified > modified) {
modified = submodified;
}

View File

@ -16,6 +16,8 @@
*/
package brut.util;
import java.util.Objects;
public class Duo<T1, T2> {
public final T1 m1;
public final T2 m2;
@ -34,13 +36,10 @@ public class Duo<T1, T2> {
return false;
}
final Duo<T1, T2> other = (Duo<T1, T2>) obj;
if (this.m1 != other.m1 && (this.m1 == null || !this.m1.equals(other.m1))) {
if (!Objects.equals(this.m1, other.m1)) {
return false;
}
if (this.m2 != other.m2 && (this.m2 == null || !this.m2.equals(other.m2))) {
return false;
}
return true;
return Objects.equals(this.m2, other.m2);
}
@Override

View File

@ -80,9 +80,9 @@ public class ExtDataInput extends DataInputDelegate {
*/
public final int skipBytes(int n) throws IOException {
int total = 0;
int cur = 0;
int cur;
while ((total < n) && ((cur = (int) super.skipBytes(n - total)) > 0)) {
while ((total < n) && ((cur = super.skipBytes(n - total)) > 0)) {
total += cur;
}

View File

@ -27,7 +27,7 @@ import java.util.concurrent.ThreadLocalRandom;
public abstract class Jar {
private static final Map<String, File> mExtracted = new HashMap<>();
public static File getResourceAsFile(String name, Class clazz) throws BrutException {
public static File getResourceAsFile(String name, Class<?> clazz) throws BrutException {
File file = mExtracted.get(name);
if (file == null) {
file = extractToTmp(name, clazz);
@ -36,11 +36,11 @@ public abstract class Jar {
return file;
}
public static File extractToTmp(String resourcePath, Class clazz) throws BrutException {
public static File extractToTmp(String resourcePath, Class<?> clazz) throws BrutException {
return extractToTmp(resourcePath, "brut_util_Jar_", clazz);
}
public static File extractToTmp(String resourcePath, String tmpPrefix, Class clazz) throws BrutException {
public static File extractToTmp(String resourcePath, String tmpPrefix, Class<?> clazz) throws BrutException {
try {
InputStream in = clazz.getResourceAsStream(resourcePath);
if (in == null) {