2121#include " Firestore/core/src/api/document_reference.h"
2222#include " Firestore/core/src/model/resource_path.h"
2323#include " Firestore/core/src/util/hashing.h"
24+ #include " absl/types/optional.h"
2425
2526namespace firebase {
2627namespace firestore {
@@ -35,22 +36,21 @@ DocumentSnapshot DocumentSnapshot::FromDocument(
3536 std::shared_ptr<Firestore> firestore,
3637 model::Document document,
3738 SnapshotMetadata metadata) {
38- return DocumentSnapshot{std::move (firestore), document->key (),
39- Optional<model::Document>(document),
39+ return DocumentSnapshot{std::move (firestore), document->key (), document,
4040 std::move (metadata)};
4141}
4242
4343DocumentSnapshot DocumentSnapshot::FromNoDocument (
4444 std::shared_ptr<Firestore> firestore,
4545 model::DocumentKey key,
4646 SnapshotMetadata metadata) {
47- return DocumentSnapshot{std::move (firestore), std::move (key),
48- Optional<model::Document>(), std::move (metadata)};
47+ return DocumentSnapshot{std::move (firestore), std::move (key), absl:: nullopt ,
48+ std::move (metadata)};
4949}
5050
5151DocumentSnapshot::DocumentSnapshot (std::shared_ptr<Firestore> firestore,
5252 model::DocumentKey document_key,
53- Optional <Document> document,
53+ absl::optional <Document> document,
5454 SnapshotMetadata metadata)
5555 : firestore_{std::move (firestore)},
5656 internal_key_{std::move (document_key)},
@@ -67,7 +67,7 @@ bool DocumentSnapshot::exists() const {
6767 return internal_document_.has_value ();
6868}
6969
70- const Optional <Document>& DocumentSnapshot::internal_document () const {
70+ const absl::optional <Document>& DocumentSnapshot::internal_document () const {
7171 return internal_document_;
7272}
7373
@@ -79,15 +79,10 @@ const std::string& DocumentSnapshot::document_id() const {
7979 return internal_key_.path ().last_segment ();
8080}
8181
82- Optional <google_firestore_v1_Value> DocumentSnapshot::GetValue (
82+ absl::optional <google_firestore_v1_Value> DocumentSnapshot::GetValue (
8383 const FieldPath& field_path) const {
84- if (internal_document_) {
85- auto value = (*internal_document_)->field (field_path);
86- if (value) {
87- return Optional<google_firestore_v1_Value>(value.value ());
88- }
89- }
90- return {};
84+ return internal_document_ ? (*internal_document_)->field (field_path)
85+ : absl::nullopt ;
9186}
9287
9388bool operator ==(const DocumentSnapshot& lhs, const DocumentSnapshot& rhs) {
0 commit comments