aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-05-06 14:12:20 -0700
committerGravatar GitHub <noreply@github.com>2018-05-06 14:12:20 -0700
commit04a28fce81c737b6505e6c542a14d8529c9f891d (patch)
treee49c433fd6726a70efc280f1b5f4025e64da7f28 /Firestore/core/src
parent5af6de9e69b86ab94da78b9f889b96517cec47da (diff)
Make BasePath hash directly as a range (#1232)
Remove BasePath.Hash() Objective-C compatibility method Make DocumentKey's hasher use BasePath's segment-based hash code.
Diffstat (limited to 'Firestore/core/src')
-rw-r--r--Firestore/core/src/firebase/firestore/model/base_path.h8
-rw-r--r--Firestore/core/src/firebase/firestore/model/document_key.h2
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_mask.h7
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_transform.h5
4 files changed, 5 insertions, 17 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/base_path.h b/Firestore/core/src/firebase/firestore/model/base_path.h
index 59a9b5a..58df6f0 100644
--- a/Firestore/core/src/firebase/firestore/model/base_path.h
+++ b/Firestore/core/src/firebase/firestore/model/base_path.h
@@ -160,14 +160,6 @@ class BasePath {
return segments_ >= rhs.segments_;
}
-#if defined(__OBJC__)
- // For Objective-C++ hash; to be removed after migration.
- // Do NOT use in C++ code.
- size_t Hash() const {
- return util::Hash(segments_);
- }
-#endif // defined(__OBJC__)
-
protected:
BasePath() = default;
template <typename IterT>
diff --git a/Firestore/core/src/firebase/firestore/model/document_key.h b/Firestore/core/src/firebase/firestore/model/document_key.h
index f6f4bf1..3f5f342 100644
--- a/Firestore/core/src/firebase/firestore/model/document_key.h
+++ b/Firestore/core/src/firebase/firestore/model/document_key.h
@@ -121,7 +121,7 @@ inline bool operator>=(const DocumentKey& lhs, const DocumentKey& rhs) {
struct DocumentKeyHash {
size_t operator()(const DocumentKey& key) const {
- return util::Hash(key.ToString());
+ return util::Hash(key.path());
}
};
diff --git a/Firestore/core/src/firebase/firestore/model/field_mask.h b/Firestore/core/src/firebase/firestore/model/field_mask.h
index 6075519..431e05a 100644
--- a/Firestore/core/src/firebase/firestore/model/field_mask.h
+++ b/Firestore/core/src/firebase/firestore/model/field_mask.h
@@ -23,6 +23,7 @@
#include <vector>
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
+#include "Firestore/core/src/firebase/firestore/util/hashing.h"
namespace firebase {
namespace firestore {
@@ -86,11 +87,7 @@ class FieldMask {
}
NSUInteger Hash() const {
- NSUInteger hashResult = 0;
- for (const FieldPath& field : fields_) {
- hashResult = hashResult * 31u + field.Hash();
- }
- return hashResult;
+ return util::Hash(fields_);
}
#endif
diff --git a/Firestore/core/src/firebase/firestore/model/field_transform.h b/Firestore/core/src/firebase/firestore/model/field_transform.h
index a1dd96c..1a7127a 100644
--- a/Firestore/core/src/firebase/firestore/model/field_transform.h
+++ b/Firestore/core/src/firebase/firestore/model/field_transform.h
@@ -22,6 +22,7 @@
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
+#include "Firestore/core/src/firebase/firestore/util/hashing.h"
namespace firebase {
namespace firestore {
@@ -51,9 +52,7 @@ class FieldTransform {
// For Objective-C++ hash; to be removed after migration.
// Do NOT use in C++ code.
NSUInteger Hash() const {
- NSUInteger hash = path_.Hash();
- hash = hash * 31 + transformation_->Hash();
- return hash;
+ return util::Hash(path_, transformation_->Hash());
}
#endif // defined(__OBJC__)