Skip to content

Commit 4cf4e7c

Browse files
authored
Do not erase from the map while iterating over it. (#8610)
1 parent 2f97224 commit 4cf4e7c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Firestore/core/src/local/leveldb_remote_document_cache.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,16 @@ MutableDocumentMap LevelDbRemoteDocumentCache::GetAll(
172172
MutableDocumentMap LevelDbRemoteDocumentCache::GetAllExisting(
173173
const DocumentKeySet& keys) {
174174
MutableDocumentMap docs = LevelDbRemoteDocumentCache::GetAll(keys);
175+
MutableDocumentMap result;
175176
for (const auto& kv : docs) {
176177
const DocumentKey& key = kv.first;
177178
auto& document = kv.second;
178-
if (!document.is_found_document()) {
179-
docs = docs.erase(key);
179+
if (document.is_found_document()) {
180+
result = result.insert(key, document);
180181
}
181182
}
182183

183-
return docs;
184+
return result;
184185
}
185186

186187
MutableDocumentMap LevelDbRemoteDocumentCache::GetMatching(

0 commit comments

Comments
 (0)