File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
firebase-database-collection/src/main/java/com/google/firebase/database/collection
src/main/java/com/google/firebase/firestore/core Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,22 @@ public ImmutableSortedSet<T> insert(T entry) {
87
87
return new ImmutableSortedSet <T >(map .insert (entry , null ));
88
88
}
89
89
90
+ public ImmutableSortedSet <T > unionWith (ImmutableSortedSet <T > other ) {
91
+ ImmutableSortedSet <T > result = this ;
92
+
93
+ // Make sure `result` always refers to the larger one of the two sets.
94
+ if (result .size () < other .size ()) {
95
+ result = other ;
96
+ other = this ;
97
+ }
98
+
99
+ for (T elem : other ) {
100
+ result = result .insert (elem );
101
+ }
102
+
103
+ return result ;
104
+ }
105
+
90
106
public T getMinEntry () {
91
107
return this .map .getMinKey ();
92
108
}
Original file line number Diff line number Diff line change 1
1
# Unreleased
2
+ - [ fixed] Fixed a performance regression introduced by the addition of
3
+ ` Query.limitToLast(n: long) ` in Firestore 23.3.1.
2
4
- [ changed] Changed the in-memory representation of Firestore documents to
3
5
reduce memory allocations and improve performance. Calls to
4
6
` DocumentSnapshot.getData() ` and ` DocumentSnapshot.toObject() ` will see
Original file line number Diff line number Diff line change @@ -354,17 +354,17 @@ public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
354
354
if (limboResolution != null && limboResolution .receivedDocument ) {
355
355
return DocumentKey .emptyKeySet ().insert (limboResolution .key );
356
356
} else {
357
- List <DocumentKey > remoteKeys = Lists . newArrayList ();
357
+ ImmutableSortedSet <DocumentKey > remoteKeys = DocumentKey . emptyKeySet ();
358
358
if (queriesByTarget .containsKey (targetId )) {
359
359
for (Query query : queriesByTarget .get (targetId )) {
360
360
if (queryViewsByQuery .containsKey (query )) {
361
- remoteKeys . addAll (
362
- Lists . newArrayList (queryViewsByQuery .get (query ).getView ().getSyncedDocuments () ));
361
+ remoteKeys =
362
+ remoteKeys . unionWith (queryViewsByQuery .get (query ).getView ().getSyncedDocuments ());
363
363
}
364
364
}
365
365
}
366
366
367
- return new ImmutableSortedSet ( remoteKeys , DocumentKey . comparator ()) ;
367
+ return remoteKeys ;
368
368
}
369
369
}
370
370
You can’t perform that action at this time.
0 commit comments