Skip to content

Commit 02b2f7a

Browse files
committed
reduce diff from main branch, to make it easier for code review
1 parent 5c10ab1 commit 02b2f7a

File tree

6 files changed

+194
-211
lines changed

6 files changed

+194
-211
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static com.google.firebase.firestore.util.Assert.hardAssert;
1818

1919
import androidx.annotation.NonNull;
20-
import com.google.firebase.firestore.util.Utf8Compare;
2120
import com.google.firebase.firestore.util.Util;
2221
import java.util.ArrayList;
2322
import java.util.List;
@@ -115,7 +114,7 @@ private static int compareSegments(String lhs, String rhs) {
115114
} else if (isLhsNumeric && isRhsNumeric) { // both numeric
116115
return Long.compare(extractNumericId(lhs), extractNumericId(rhs));
117116
} else { // both string
118-
return Utf8Compare.compareUtf8Strings(lhs, rhs);
117+
return Util.compareUtf8Strings(lhs, rhs);
119118
}
120119
}
121120

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static com.google.firebase.firestore.util.Assert.hardAssert;
2121

2222
import androidx.annotation.Nullable;
23-
import com.google.firebase.firestore.util.Utf8Compare;
2423
import com.google.firebase.firestore.util.Util;
2524
import com.google.firestore.v1.ArrayValue;
2625
import com.google.firestore.v1.ArrayValueOrBuilder;
@@ -231,7 +230,7 @@ public static int compare(Value left, Value right) {
231230
case TYPE_ORDER_SERVER_TIMESTAMP:
232231
return compareTimestamps(getLocalWriteTime(left), getLocalWriteTime(right));
233232
case TYPE_ORDER_STRING:
234-
return Utf8Compare.compareUtf8Strings(left.getStringValue(), right.getStringValue());
233+
return Util.compareUtf8Strings(left.getStringValue(), right.getStringValue());
235234
case TYPE_ORDER_BLOB:
236235
return Util.compareByteStrings(left.getBytesValue(), right.getBytesValue());
237236
case TYPE_ORDER_REFERENCE:
@@ -350,7 +349,7 @@ private static int compareMaps(MapValue left, MapValue right) {
350349
while (iterator1.hasNext() && iterator2.hasNext()) {
351350
Map.Entry<String, Value> entry1 = iterator1.next();
352351
Map.Entry<String, Value> entry2 = iterator2.next();
353-
int keyCompare = Utf8Compare.compareUtf8Strings(entry1.getKey(), entry2.getKey());
352+
int keyCompare = Util.compareUtf8Strings(entry1.getKey(), entry2.getKey());
354353
if (keyCompare != 0) {
355354
return keyCompare;
356355
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import com.google.firebase.firestore.BuildConfig;
2323
import com.google.protobuf.ByteString;
2424

25-
public final class Utf8Compare {
25+
/**
26+
* This class provides the implementation of {@link Util#compareUtf8Strings}.
27+
*/
28+
final class Utf8Compare {
2629

2730
private Utf8Compare() {}
2831

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public static int compareIntegers(int i1, int i2) {
8585
}
8686
}
8787

88+
/** Compare strings in UTF-8 encoded byte order */
89+
public static int compareUtf8Strings(String left, String right) {
90+
return Utf8Compare.compareUtf8Strings(left, right);
91+
}
92+
8893
/**
8994
* Utility function to compare longs. Note that we can't use Long.compare because it's only
9095
* available after Android 19.

firebase-firestore/src/test/java/com/google/firebase/firestore/util/Utf8CompareTest.java

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)