Skip to content

Commit 895126f

Browse files
committed
value_util.cc: Fix MaxValue() to no longer use designated initialization.
This ports firebase/firebase-ios-sdk#9868 to the firebase-cpp-sdk repository by patching the firebase-ios-sdk when it is cloned. Once the dependency on the firebase-ios-sdk is updated to a version that already includes firebase/firebase-ios-sdk#9868 then this commit should be reverted.
1 parent 94b5f05 commit 895126f

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

cmake/external/firestore_snappy.patch.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,68 @@ index 000000000..28bfb0837
617617
+ const uint8_t*& ip = *ip_p;
618618
+ // This section is crucial for the throughput of the decompression loop.
619619
+ // The latency of an iteration is fundamentally constrained by the
620+
diff --git a/Firestore/core/src/model/value_util.cc b/Firestore/core/src/model/value_util.cc
621+
index 1b6bf07e0..41d1d6d26 100644
622+
--- a/Firestore/core/src/model/value_util.cc
623+
+++ b/Firestore/core/src/model/value_util.cc
624+
@@ -53,26 +53,6 @@ const char* kRawMaxValueFieldValue = "__max__";
625+
pb_bytes_array_s* kMaxValueFieldValue =
626+
nanopb::MakeBytesArray(kRawMaxValueFieldValue);
627+
628+
-/** The special map field value entry of a maximum proto value. */
629+
-google_firestore_v1_MapValue_FieldsEntry kMaxValueFieldEntry = {
630+
- .key = kMaxValueFieldKey,
631+
- .value = {
632+
- .which_value_type = google_firestore_v1_Value_string_value_tag,
633+
- .string_value = const_cast<pb_bytes_array_t*>(kMaxValueFieldValue)}};
634+
-
635+
-/** The special map value of a maximum proto value. */
636+
-_google_firestore_v1_MapValue kMaxValueMapValue = {
637+
- .fields_count = 1, .fields = &kMaxValueFieldEntry};
638+
-
639+
-/**
640+
- * A maximum value that is larger than any other Firestore values. Underlying it
641+
- * is a map value with a special map field that SDK user cannot possibly
642+
- * construct.
643+
- */
644+
-google_firestore_v1_Value kMaxValue = {
645+
- .which_value_type = google_firestore_v1_Value_map_value_tag,
646+
- .map_value = kMaxValueMapValue};
647+
-
648+
} // namespace
649+
650+
using nanopb::Message;
651+
@@ -703,8 +683,32 @@ bool IsMinValue(const google_firestore_v1_Value& value) {
652+
return IsNullValue(value);
653+
}
654+
655+
+/**
656+
+ * Creates and returns a maximum value that is larger than any other Firestore
657+
+ * values. Underlying it is a map value with a special map field that SDK user
658+
+ * cannot possibly construct.
659+
+ */
660+
google_firestore_v1_Value MaxValue() {
661+
- return kMaxValue;
662+
+ google_firestore_v1_Value value;
663+
+ value.which_value_type = google_firestore_v1_Value_string_value_tag;
664+
+ value.string_value = kMaxValueFieldValue;
665+
+
666+
+ // Make `field_entry` static so that it has a memory address that outlives
667+
+ // this function's scope; otherwise, using its address in the `map_value`
668+
+ // variable below would be invalid by the time the caller accessed it.
669+
+ static google_firestore_v1_MapValue_FieldsEntry field_entry;
670+
+ field_entry.key = kMaxValueFieldKey;
671+
+ field_entry.value = value;
672+
+
673+
+ google_firestore_v1_MapValue map_value;
674+
+ map_value.fields_count = 1;
675+
+ map_value.fields = &field_entry;
676+
+
677+
+ google_firestore_v1_Value max_value;
678+
+ max_value.which_value_type = google_firestore_v1_Value_map_value_tag;
679+
+ max_value.map_value = map_value;
680+
+
681+
+ return max_value;
682+
}
683+
684+
bool IsMaxValue(const google_firestore_v1_Value& value) {

0 commit comments

Comments
 (0)