File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Firestore/core/src/firebase/firestore Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -402,10 +402,8 @@ DocumentKeySet SyncEngine::GetRemoteKeys(TargetId target_id) const {
402
402
}
403
403
404
404
for (const auto & query : queries_by_target_.at (target_id)) {
405
- for (const auto & key :
406
- query_views_by_query_.at (query)->view ().synced_documents ()) {
407
- keys = keys.insert (key);
408
- }
405
+ keys = keys.union_with (
406
+ query_views_by_query_.at (query)->view ().synced_documents ());
409
407
}
410
408
return keys;
411
409
}
Original file line number Diff line number Diff line change @@ -74,6 +74,23 @@ class SortedSet : public SortedContainer {
74
74
return SortedSet{map_.insert (key, {})};
75
75
}
76
76
77
+ ABSL_MUST_USE_RESULT SortedSet union_with (const SortedSet& other) const {
78
+ const SortedSet* result_ptr = this ;
79
+ const SortedSet* other_ptr = &other;
80
+
81
+ // Make sure `result_ptr` always points to the larger one of the two sets.
82
+ if (result_ptr->size () < other_ptr->size ()) {
83
+ result_ptr = other_ptr;
84
+ other_ptr = this ;
85
+ }
86
+
87
+ auto result = *result_ptr;
88
+ for (const auto & k : *other_ptr) {
89
+ result = result.insert (k);
90
+ }
91
+ return result;
92
+ }
93
+
77
94
ABSL_MUST_USE_RESULT SortedSet erase (const K& key) const {
78
95
return SortedSet{map_.erase (key)};
79
96
}
You can’t perform that action at this time.
0 commit comments