mirror of
https://github.com/revanced/smali.git
synced 2025-05-02 15:44:30 +02:00
Check whether we have a next element instead of accessing it and catching the exception. Exceptions are notoriously slow in Java, so we want to avoid that.
This commit is contained in:
parent
78a829342f
commit
85334314da
@ -78,11 +78,10 @@ public class CollectionUtils {
|
|||||||
Iterator<? extends T> elements2 = it2.iterator();
|
Iterator<? extends T> elements2 = it2.iterator();
|
||||||
for (T element1: it1) {
|
for (T element1: it1) {
|
||||||
T element2;
|
T element2;
|
||||||
try {
|
if (!elements2.hasNext()) {
|
||||||
element2 = elements2.next();
|
|
||||||
} catch (NoSuchElementException ex) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
element2 = elements2.next();
|
||||||
int res = comparator.compare(element1, element2);
|
int res = comparator.compare(element1, element2);
|
||||||
if (res != 0) return res;
|
if (res != 0) return res;
|
||||||
}
|
}
|
||||||
@ -97,11 +96,10 @@ public class CollectionUtils {
|
|||||||
Iterator<? extends T> elements2 = it2.iterator();
|
Iterator<? extends T> elements2 = it2.iterator();
|
||||||
for (T element1: it1) {
|
for (T element1: it1) {
|
||||||
T element2;
|
T element2;
|
||||||
try {
|
if (!elements2.hasNext()) {
|
||||||
element2 = elements2.next();
|
|
||||||
} catch (NoSuchElementException ex) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
element2 = elements2.next();
|
||||||
int res = element1.compareTo(element2);
|
int res = element1.compareTo(element2);
|
||||||
if (res != 0) return res;
|
if (res != 0) return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user