Skip to content

Commit 622ed5a

Browse files
Refactor compareLong method using Long.compare, corrected the local variable name (#1136)
1 parent 67644de commit 622ed5a

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

webmagic-core/src/main/java/us/codecraft/webmagic/utils/NumberUtils.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
public abstract class NumberUtils {
77

88
public static int compareLong(long o1, long o2) {
9-
if (o1 < o2) {
10-
return -1;
11-
} else if (o1 == o2) {
12-
return 0;
13-
} else {
14-
return 1;
15-
}
9+
return Long.compare(o1, o2);
1610
}
1711
}

webmagic-core/src/main/java/us/codecraft/webmagic/utils/WMCollections.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public static <T> Set<T> newHashSet(T... t){
2121
}
2222

2323
public static <T> List<T> newArrayList(T... t){
24-
List<T> set = new ArrayList<T>(t.length);
24+
List<T> list = new ArrayList<T>(t.length);
2525
for (T t1 : t) {
26-
set.add(t1);
26+
list.add(t1);
2727
}
28-
return set;
28+
return list;
2929
}
3030
}

0 commit comments

Comments
 (0)