17
17
#include " Firestore/core/src/model/object_value.h"
18
18
19
19
#include < algorithm>
20
+ #include < map>
20
21
#include < set>
21
22
22
23
#include " Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h"
23
24
#include " Firestore/core/src/nanopb/fields_array.h"
24
25
#include " Firestore/core/src/nanopb/message.h"
25
26
#include " Firestore/core/src/nanopb/nanopb_util.h"
26
- #include " absl/container/flat_hash_map.h"
27
- #include " absl/container/flat_hash_set.h"
28
27
29
28
namespace firebase {
30
29
namespace firestore {
@@ -75,16 +74,16 @@ google_firestore_v1_MapValue_FieldsEntry* FindEntry(
75
74
76
75
size_t CalculateSizeOfUnion (
77
76
google_firestore_v1_MapValue* map_value,
78
- const absl::flat_hash_map <std::string, google_firestore_v1_Value>& upserts,
79
- const absl::flat_hash_set <std::string>& deletes) {
77
+ const std::map <std::string, google_firestore_v1_Value>& upserts,
78
+ const std::set <std::string>& deletes) {
80
79
// Compute the size of the map after applying all mutations. The final size is
81
80
// the number of existing entries, plus the number of new entries
82
81
// minus the number of deleted entries.
83
82
return upserts.size () +
84
83
std::count_if (
85
84
map_value->fields , map_value->fields + map_value->fields_count ,
86
85
[&](const google_firestore_v1_MapValue_FieldsEntry& entry) {
87
- absl::string_view field = MakeStringView (entry.key );
86
+ std::string field = MakeString (entry.key );
88
87
// Don't count if entry is deleted or if it is a replacement
89
88
// rather than an insert.
90
89
return deletes.find (field) == deletes.end () &&
@@ -98,8 +97,8 @@ size_t CalculateSizeOfUnion(
98
97
*/
99
98
void ApplyChanges (
100
99
google_firestore_v1_MapValue* parent,
101
- const absl::flat_hash_map <std::string, google_firestore_v1_Value>& upserts,
102
- const absl::flat_hash_set <std::string>& deletes) {
100
+ const std::map <std::string, google_firestore_v1_Value>& upserts,
101
+ const std::set <std::string>& deletes) {
103
102
// TODO(mrschmidt): Consider using `absl::btree_map` and `absl::btree_set` for
104
103
// potentially better performance.
105
104
auto source_count = parent->fields_count ;
@@ -228,7 +227,7 @@ void MutableObjectValue::Set(const FieldPath& path,
228
227
google_firestore_v1_MapValue* parent_map = ParentMap (path.PopLast ());
229
228
230
229
std::string last_segment = path.last_segment ();
231
- absl::flat_hash_map <std::string, google_firestore_v1_Value> upserts{
230
+ std::map <std::string, google_firestore_v1_Value> upserts{
232
231
{std::move (last_segment), value}};
233
232
234
233
ApplyChanges (parent_map, upserts, /* deletes=*/ {});
@@ -238,8 +237,8 @@ void MutableObjectValue::SetAll(const FieldMask& field_mask,
238
237
const MutableObjectValue& data) {
239
238
FieldPath parent;
240
239
241
- absl::flat_hash_map <std::string, google_firestore_v1_Value> upserts;
242
- absl::flat_hash_set <std::string> deletes;
240
+ std::map <std::string, google_firestore_v1_Value> upserts;
241
+ std::set <std::string> deletes;
243
242
244
243
for (const FieldPath& path : field_mask) {
245
244
if (!parent.IsImmediateParentOf (path)) {
@@ -280,7 +279,7 @@ void MutableObjectValue::Delete(const FieldPath& path) {
280
279
// We can only delete a leaf entry if its parent is a map.
281
280
if (nested_value->which_value_type ==
282
281
google_firestore_v1_Value_map_value_tag) {
283
- absl::flat_hash_set <std::string> deletes{path.last_segment ()};
282
+ std::set <std::string> deletes{path.last_segment ()};
284
283
ApplyChanges (&nested_value->map_value , /* upserts=*/ {}, deletes);
285
284
}
286
285
}
@@ -314,7 +313,7 @@ google_firestore_v1_MapValue* MutableObjectValue::ParentMap(
314
313
google_firestore_v1_Value new_entry{};
315
314
new_entry.which_value_type = google_firestore_v1_Value_map_value_tag;
316
315
317
- absl::flat_hash_map <std::string, google_firestore_v1_Value> upserts{
316
+ std::map <std::string, google_firestore_v1_Value> upserts{
318
317
{segment, new_entry}};
319
318
ApplyChanges (&parent->map_value , upserts, /* deletes=*/ {});
320
319
0 commit comments