diff options
author | Gil <mcg@google.com> | 2018-01-19 12:27:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 12:27:11 -0800 |
commit | 39d8252300015c26f1932cff42032613fdb36a09 (patch) | |
tree | 93bb3ab7c476289c4afe6cf91773a60b6f53a94d /Firestore/Source/API | |
parent | 9f7c094f9f00a6efc0107071f109ef1bc4d7357d (diff) |
Port comparison to C++ (#678)
This reimplements our comparison functions as C++ Comparators and then provides compatibility shims for interoperating with existing Objective-C usage.
A few specialized comparators aren't suitable for porting but only have a single usage (e.g. CompareBytes for comparing NSData * instances). In these cases I've moved them into the caller.
* Use int32_t for typeof(ID) in FSTDocumentReference
* Migrate callers of FSTComparison.h to Objective-C++
* Port comparison to C++
* Migrate usages of FSTComparison.h to C++ equivalents
* Remove FSTComparison
Diffstat (limited to 'Firestore/Source/API')
-rw-r--r-- | Firestore/Source/API/FIRGeoPoint.mm (renamed from Firestore/Source/API/FIRGeoPoint.m) | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Firestore/Source/API/FIRGeoPoint.m b/Firestore/Source/API/FIRGeoPoint.mm index 72e9e7d..8d89633 100644 --- a/Firestore/Source/API/FIRGeoPoint.m +++ b/Firestore/Source/API/FIRGeoPoint.mm @@ -16,9 +16,14 @@ #import "Firestore/Source/API/FIRGeoPoint+Internal.h" -#import "Firestore/Source/Util/FSTComparison.h" +#import "Firestore/core/src/firebase/firestore/util/comparison.h" + #import "Firestore/Source/Util/FSTUsageValidation.h" +using firebase::firestore::util::DoubleBitwiseEquals; +using firebase::firestore::util::DoubleBitwiseHash; +using firebase::firestore::util::WrapCompare; + NS_ASSUME_NONNULL_BEGIN @implementation FIRGeoPoint @@ -45,11 +50,11 @@ NS_ASSUME_NONNULL_BEGIN } - (NSComparisonResult)compare:(FIRGeoPoint *)other { - NSComparisonResult result = FSTCompareDoubles(self.latitude, other.latitude); + NSComparisonResult result = WrapCompare<double>(self.latitude, other.latitude); if (result != NSOrderedSame) { return result; } else { - return FSTCompareDoubles(self.longitude, other.longitude); + return WrapCompare<double>(self.longitude, other.longitude); } } @@ -67,12 +72,12 @@ NS_ASSUME_NONNULL_BEGIN return NO; } FIRGeoPoint *otherGeoPoint = (FIRGeoPoint *)other; - return FSTDoubleBitwiseEquals(self.latitude, otherGeoPoint.latitude) && - FSTDoubleBitwiseEquals(self.longitude, otherGeoPoint.longitude); + return DoubleBitwiseEquals(self.latitude, otherGeoPoint.latitude) && + DoubleBitwiseEquals(self.longitude, otherGeoPoint.longitude); } - (NSUInteger)hash { - return 31 * FSTDoubleBitwiseHash(self.latitude) + FSTDoubleBitwiseHash(self.longitude); + return 31 * DoubleBitwiseHash(self.latitude) + DoubleBitwiseHash(self.longitude); } /** Implements NSCopying without actually copying because geopoints are immutable. */ |