diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-09-23 21:03:16 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-09-23 21:03:16 +0000 |
commit | 45d87eb8a0ebb19f34a943196479bd17bc1e9291 (patch) | |
tree | 0b28a8eea68a4f16a03561e7237b976e5489c548 | |
parent | 1fcb7fd306080b918465b8a392c799ac2f4accfd (diff) | |
parent | 2ab145decd710cf60c7b7ad65567282e09051e82 (diff) | |
download | puffin-45d87eb8a0ebb19f34a943196479bd17bc1e9291.tar.gz |
Add comparison operator for bitextent am: 44c83ceeac am: 2ab145decd
Original change: https://android-review.googlesource.com/c/platform/external/puffin/+/1835273
Change-Id: Ib780678bebbb8b864ce1436c6f00efba8754abe3
-rw-r--r-- | src/include/puffin/common.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/include/puffin/common.h b/src/include/puffin/common.h index 954b7d9..07b8589 100644 --- a/src/include/puffin/common.h +++ b/src/include/puffin/common.h @@ -43,12 +43,18 @@ struct ByteExtent { }; struct BitExtent { - BitExtent(uint64_t offset, uint64_t length) + constexpr BitExtent(uint64_t offset, uint64_t length) : offset(offset), length(length) {} - bool operator==(const BitExtent& other) const { + constexpr bool operator==(const BitExtent& other) const { return this->length == other.length && this->offset == other.offset; } + constexpr bool operator<(const BitExtent& other) const { + if (offset != other.offset) { + return offset < other.offset; + } + return length < other.length; + } uint64_t offset; uint64_t length; |