Skip to content

Commit 95fb37b

Browse files
committed
Remove Use Long.compare() instead of Util.compareLongs() too
1 parent 6cfb8be commit 95fb37b

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* [fixed] Further improved performance of UTF-8 string ordering logic,
33
which had degraded in v25.1.2 and received some improvements in v25.1.3.
44
[#7053](//github.com/firebase/firebase-android-sdk/issues/7053)
5-
* [changed] Use `Integer.compare()` (which was added in Android API 19) to compare integers instead
6-
of Firestore's bespoke implementation, since minSdkVersion has been greater than 19 for some time.
5+
* [changed] Use `Integer.compare()` and `Long.compare()` (which were added in Android API 19)
6+
instead of Firestore's bespoke implementations, since minSdkVersion is greater than 19.
77
[#7109](//github.com/firebase/firebase-android-sdk/pull/7109)
88

99

firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static int firestoreCompareDoubleWithLong(double doubleValue, long longVa
5050
}
5151

5252
long doubleAsLong = (long) doubleValue;
53-
int cmp = compareLongs(doubleAsLong, longValue);
53+
int cmp = Long.compare(doubleAsLong, longValue);
5454
if (cmp != 0) {
5555
return cmp;
5656
}
@@ -60,11 +60,6 @@ public static int firestoreCompareDoubleWithLong(double doubleValue, long longVa
6060
return firestoreCompareDoubles(doubleValue, longAsDouble);
6161
}
6262

63-
/** Compares longs. */
64-
public static int compareLongs(long leftLong, long rightLong) {
65-
return Long.compare(leftLong, rightLong);
66-
}
67-
6863
/**
6964
* Compares doubles with Firestore query semantics: NaN precedes all other numbers and equals
7065
* itself, all zeroes are equal.

firebase-firestore/src/main/java/com/google/firebase/firestore/model/Values.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private static int compareNumbers(Value left, Value right) {
291291
} else if (left.getValueTypeCase() == Value.ValueTypeCase.INTEGER_VALUE) {
292292
long leftLong = left.getIntegerValue();
293293
if (right.getValueTypeCase() == Value.ValueTypeCase.INTEGER_VALUE) {
294-
return Util.compareLongs(leftLong, right.getIntegerValue());
294+
return Long.compare(leftLong, right.getIntegerValue());
295295
} else if (right.getValueTypeCase() == Value.ValueTypeCase.DOUBLE_VALUE) {
296296
return -1 * Util.compareMixed(right.getDoubleValue(), leftLong);
297297
}
@@ -301,7 +301,7 @@ private static int compareNumbers(Value left, Value right) {
301301
}
302302

303303
private static int compareTimestamps(Timestamp left, Timestamp right) {
304-
int cmp = Util.compareLongs(left.getSeconds(), right.getSeconds());
304+
int cmp = Long.compare(left.getSeconds(), right.getSeconds());
305305
if (cmp != 0) {
306306
return cmp;
307307
}

firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ public static int compareUtf8Strings(String left, String right) {
115115
return Integer.compare(left.length(), right.length());
116116
}
117117

118-
/**
119-
* Utility function to compare longs. Note that we can't use Long.compare because it's only
120-
* available after Android 19.
121-
*/
122-
public static int compareLongs(long i1, long i2) {
123-
return NumberComparisonHelper.compareLongs(i1, i2);
124-
}
125-
126118
/** Utility function to compare doubles (using Firestore semantics for NaN). */
127119
public static int compareDoubles(double i1, double i2) {
128120
return NumberComparisonHelper.firestoreCompareDoubles(i1, i2);

0 commit comments

Comments
 (0)