Skip to content

Commit

Permalink
Syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed May 21, 2024
1 parent 7981fb2 commit c5e70f6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/libj/util/CircularArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public boolean addAll(final Collection<? extends E> c) {
}
else {
final Iterator<? extends E> it = c.iterator();
do { // [RA]
do { // [I]
elementData[tail] = it.next();
tail = ++tail % elementData.length;
++size;
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/libj/util/CollectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public static boolean equals(final Collection<?> a, final Collection<?> b) {

final List<?> la, lb;
if (a instanceof List && isRandomAccess(la = (List<?>)a)) {
int i = 0;
if (b instanceof List && isRandomAccess(lb = (List<?>)b)) {
int i = 0;
do { // [RA]
if (!Objects.equals(la.get(i), lb.get(i)))
return false;
Expand All @@ -143,8 +143,7 @@ public static boolean equals(final Collection<?> a, final Collection<?> b) {
}
else {
final Iterator<?> ib = b.iterator();
int i = 0;
do { // [RA]
do { // [I]
if (!Objects.equals(la.get(i), ib.next()))
return false;
}
Expand All @@ -153,8 +152,8 @@ public static boolean equals(final Collection<?> a, final Collection<?> b) {
}
else {
final Iterator<?> ia = a.iterator();
int i = 0;
if (b instanceof List && isRandomAccess(lb = (List<?>)b)) {
int i = 0;
do { // [RA]
if (!Objects.equals(ia.next(), lb.get(i)))
return false;
Expand All @@ -163,7 +162,6 @@ public static boolean equals(final Collection<?> a, final Collection<?> b) {
}
else {
final Iterator<?> ib = b.iterator();
int i = 0;
do { // [I]
if (!Objects.equals(ia.next(), ib.next()))
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/libj/util/Locales.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,18 @@ public static Locale[] parse(final Collection<String> strings) {
if (i$ == 0)
return EMPTY_LOCALES;

int i = 0;
final Locale[] locales = new Locale[i$];
final List<String> list;
if (strings instanceof List && CollectionUtil.isRandomAccess(list = (List<String>)strings)) {
int i = 0;
do // [RA]
locales[i] = parse(list.get(i));
while (++i < i$);
}
else {
int i = -1;
final Iterator<String> it = strings.iterator();
do // [I]
locales[++i] = parse(it.next());
locales[i++] = parse(it.next());
while (it.hasNext());
}

Expand Down
33 changes: 9 additions & 24 deletions src/main/java/org/libj/util/ObservableList.java
Original file line number Diff line number Diff line change
Expand Up @@ -1050,50 +1050,35 @@ public boolean equals(final Object obj) {
if (i$ == 0)
return true;

int i = 0;
if (isRandomAccess()) {
if (CollectionUtil.isRandomAccess(that)) {
int i = 0;
do { // [RA]
final Object e1 = get(i);
final Object e2 = that.get(i);
if (!equals(e1, e2))
do // [RA]
if (!equals(get(i), that.get(i)))
return false;
}
while (++i < i$);
}
else {
final Iterator<?> thatIt = that.iterator();
int i = 0;
do { // [I]
final Object e1 = get(i);
final Object e2 = thatIt.next();
if (!equals(e1, e2))
do // [I]
if (!equals(get(i), thatIt.next()))
return false;
}
while (++i < i$);
}
}
else if (CollectionUtil.isRandomAccess(that)) {
final Iterator<?> thisIt = that.iterator();
int i = 0;
do { // [RA]
final Object e1 = thisIt.next();
final Object e2 = that.get(i);
if (!equals(e1, e2))
do // [RA]
if (!equals(thisIt.next(), that.get(i)))
return false;
}
while (++i < i$);
}
else {
final Iterator<?> thisIt = that.iterator();
final Iterator<?> thatIt = that.iterator();
int i = 0;
do { // [I]
final Object e1 = thisIt.next();
final Object e2 = thatIt.next();
if (!equals(e1, e2))
do // [I]
if (!equals(thisIt.next(), thatIt.next()))
return false;
}
while (++i < i$);
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/libj/util/concurrent/ExecutorServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,21 @@ public static <T,R> List<Future<R>> invokeAll(final ExecutorService executor, fi
if (size == 0)
return Collections.EMPTY_LIST;

int i = 0;
final Callable<R>[] callables = new Callable[size];
final List<T> list;
if (tasks instanceof List && CollectionUtil.isRandomAccess(list = (List<T>)tasks)) {
int i = 0;
do { // [RA]
final T task = Objects.requireNonNull(list.get(i));
callables[i] = () -> proxy.apply(task);
}
while (++i < size);
}
else {
int i = -1;
final Iterator<T> it = tasks.iterator();
do { // [I]
final T task = Objects.requireNonNull(it.next());
callables[++i] = () -> proxy.apply(task);
callables[i++] = () -> proxy.apply(task);
}
while (it.hasNext());
}
Expand Down

0 comments on commit c5e70f6

Please sign in to comment.