diff options
| author | Dan Engelbrecht <[email protected]> | 2022-05-10 15:57:04 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-05-11 16:14:17 +0200 |
| commit | 68f7940692332ac648d249212064a090fe2b72f4 (patch) | |
| tree | 9da957bcf19b8f8413595adb65b81560d4df8f6e | |
| parent | Add namespace test (diff) | |
| download | zen-68f7940692332ac648d249212064a090fe2b72f4.tar.xz zen-68f7940692332ac648d249212064a090fe2b72f4.zip | |
use spaceship operator for CacheKey comparisons
| -rw-r--r-- | zenutil/include/zenutil/cache/cachekey.h | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/zenutil/include/zenutil/cache/cachekey.h b/zenutil/include/zenutil/cache/cachekey.h index e6110a522..9d0a4ba6d 100644 --- a/zenutil/include/zenutil/cache/cachekey.h +++ b/zenutil/include/zenutil/cache/cachekey.h @@ -21,31 +21,11 @@ struct CacheKey return {.Namespace = ToLower(Namespace), .Bucket = ToLower(Bucket), .Hash = Hash}; } + auto operator<=>(const CacheKey&) const = default; + static const CacheKey Empty; }; -inline bool -operator==(const CacheKey& A, const CacheKey& B) -{ - return A.Namespace == B.Namespace && A.Bucket == B.Bucket && A.Hash == B.Hash; -} - -inline bool -operator!=(const CacheKey& A, const CacheKey& B) -{ - return A.Namespace != B.Namespace || A.Bucket != B.Bucket || A.Hash != B.Hash; -} - -inline bool -operator<(const CacheKey& A, const CacheKey& B) -{ - const std::string& NamespaceA = A.Namespace; - const std::string& NamespaceB = B.Namespace; - const std::string& BucketA = A.Bucket; - const std::string& BucketB = B.Bucket; - return NamespaceA == NamespaceB ? (BucketA == BucketB ? A.Hash < B.Hash : BucketA < BucketB) : NamespaceA < NamespaceB; -} - struct CacheChunkRequest { CacheKey Key; |