diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-09-23 21:15:01 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-09-23 21:15:01 +0000 |
commit | aa2a1cdcc50dbd10890ebb5632d8b7f427ca99f4 (patch) | |
tree | 0b28a8eea68a4f16a03561e7237b976e5489c548 | |
parent | b2dae6e8fcd95fdcb5d8804850714ee0c318ac12 (diff) | |
parent | 45d87eb8a0ebb19f34a943196479bd17bc1e9291 (diff) | |
download | puffin-aa2a1cdcc50dbd10890ebb5632d8b7f427ca99f4.tar.gz |
Add comparison operator for bitextent am: 44c83ceeac am: 2ab145decd am: 45d87eb8a0
Original change: https://android-review.googlesource.com/c/platform/external/puffin/+/1835273
Change-Id: I3bc61982c5d3daca80311576042568eaa7a8bd21
-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; |