Skip to content

Commit

Permalink
Fix another accidental use of varargs min/max calls.
Browse files Browse the repository at this point in the history
As in cl/689775552, I'm fixing a mistaken change from cl/687381111.

RELNOTES=n/a
PiperOrigin-RevId: 691489572
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Oct 30, 2024
1 parent 5a63833 commit 7526d1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
import static java.lang.Math.min;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand Down Expand Up @@ -196,8 +195,10 @@ enum LexicographicalComparator implements Comparator<int[]> {
INSTANCE;

@Override
// A call to bare "min" or "max" would resolve to our varargs method, not to any static import.
@SuppressWarnings("StaticImportPreferred")
public int compare(int[] left, int[] right) {
int minLength = min(left.length, right.length);
int minLength = Math.min(left.length, right.length);
for (int i = 0; i < minLength; i++) {
if (left[i] != right[i]) {
return UnsignedInts.compare(left[i], right[i]);
Expand Down
5 changes: 3 additions & 2 deletions guava/src/com/google/common/primitives/UnsignedInts.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
import static java.lang.Math.min;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand Down Expand Up @@ -196,8 +195,10 @@ enum LexicographicalComparator implements Comparator<int[]> {
INSTANCE;

@Override
// A call to bare "min" or "max" would resolve to our varargs method, not to any static import.
@SuppressWarnings("StaticImportPreferred")
public int compare(int[] left, int[] right) {
int minLength = min(left.length, right.length);
int minLength = Math.min(left.length, right.length);
for (int i = 0; i < minLength; i++) {
if (left[i] != right[i]) {
return UnsignedInts.compare(left[i], right[i]);
Expand Down

0 comments on commit 7526d1b

Please sign in to comment.