Skip to content

Commit 3b9ffd2

Browse files
committed
Trivial
1 parent d9f81b3 commit 3b9ffd2

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

src/main/java/org/libj/util/ArrayUtil.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -5795,14 +5795,14 @@ public static <T> int dedupe(final T[] a, final Comparator<? super T> c) {
57955795
*
57965796
* @param a The first array to compare.
57975797
* @param b The second array to compare.
5798-
* @param cmp The comparator to compare array elements.
5798+
* @param c The comparator to compare array elements.
57995799
* @param <T> The type of array elements.
58005800
* @return The value {@code 0} if the first and second array are equal and contain the same elements in the same order; a value less
58015801
* than {@code 0} if the first array is lexicographically less than the second array; and a value greater than {@code 0} if
58025802
* the first array is lexicographically greater than the second array.
58035803
* @throws NullPointerException If the comparator is null.
58045804
*/
5805-
public static <T> int compare(final T[] a, final T[] b, final Comparator<? super T> cmp) {
5805+
public static <T> int compare(final T[] a, final T[] b, final Comparator<? super T> c) {
58065806
if (a == b)
58075807
return 0;
58085808

@@ -5812,17 +5812,19 @@ public static <T> int compare(final T[] a, final T[] b, final Comparator<? super
58125812
if (b == null)
58135813
return 1;
58145814

5815-
for (int i = 0, i$ = Math.min(a.length, b.length); i < i$; ++i) { // [A]
5815+
final int aLen = a.length;
5816+
final int bLen = b.length;
5817+
for (int i = 0, i$ = Math.min(aLen, bLen); i < i$; ++i) { // [A]
58165818
final T oa = a[i];
58175819
final T ob = b[i];
58185820
if (oa != ob) {
5819-
final int v = cmp.compare(oa, ob);
5821+
final int v = c.compare(oa, ob);
58205822
if (v != 0)
58215823
return v;
58225824
}
58235825
}
58245826

5825-
return a.length - b.length;
5827+
return aLen - bLen;
58265828
}
58275829

58285830
private ArrayUtil() {

src/main/java/org/libj/util/Dates.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ public final class Dates {
7171
public static final int MILLISECONDS_IN_WEEK = MILLISECONDS_IN_SECOND * SECONDS_IN_WEEK;
7272

7373
/**
74-
* Returns a name in the "short" style of the TimeZone specified by {@code id}. If the specified {@code date} is in Daylight Saving
75-
* Time in the TimeZone, a Daylight Saving Time name is returned (even if the TimeZone doesn't observe Daylight Saving Time).
76-
* Otherwise, a Standard Time name is returned.
74+
* Returns a name in the "short" style of the {@link TimeZone} specified by {@code id}. If the specified {@code date} is in Daylight
75+
* Saving Time in the {@link TimeZone}, a Daylight Saving Time name is returned (even if the {@link TimeZone} doesn't observe
76+
* Daylight Saving Time). Otherwise, a Standard Time name is returned.
7777
*
78-
* @param id The id of the TimeZone.
78+
* @param id The id of the {@link TimeZone}.
7979
* @param date The given date.
8080
* @return A name in the "short" style of the TimeZone specified by {@code id}.
81-
* @throws NullPointerException If {@code date} is null.
81+
* @throws NullPointerException If {@code id} or {@code date} is null.
82+
* @see TimeZone#getTimeZone(String)
8283
*/
8384
public static String getTimeZoneShortName(final String id, final Date date) {
8485
final TimeZone timezone = TimeZone.getTimeZone(id);

src/main/java/org/libj/util/SortedList.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,9 @@ private SortedList(final L list, final Comparator<E> comparator, final boolean s
7171
list.sort(comparator);
7272
}
7373

74-
private Class<?> comparatorType;
75-
76-
private Class<?> comparatorType() {
77-
return comparatorType == null ? comparatorType = (Class<?>)((ParameterizedType)comparator.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0] : comparatorType;
78-
}
79-
8074
@SuppressWarnings({"rawtypes", "unchecked"})
8175
private int indexOf(final Object o, final int fromIndex, final int toIndex) {
82-
if (comparator != DEFAULT_COMPARATOR && comparatorType().isInstance(o))
76+
if (comparator != DEFAULT_COMPARATOR)
8377
return CollectionUtil.binarySearch(target, fromIndex, toIndex, o, (Comparator)comparator);
8478

8579
if (o == null)

src/main/java/org/libj/util/Temporals.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.Date;
2929

3030
/**
31-
* Utility functions for operations pertaining to the {@code java.time} package.
31+
* Utility functions for operations pertaining to the {@link java.time} package.
3232
*/
3333
public final class Temporals {
3434
/**

src/main/java/org/libj/util/zip/Zip.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.zip.ZipOutputStream;
2727

2828
/**
29-
* Utility enum pertaining to {@code java.util.zip} package.
29+
* Utility enum pertaining to {@link java.util.zip} package.
3030
*/
3131
public enum Zip {
3232
ZIP {

0 commit comments

Comments
 (0)