summaryrefslogtreecommitdiff
path: root/payload_generator/extent_utils.h
diff options
context:
space:
mode:
authorAmin Hassani <ahassani@google.com>2017-12-06 13:47:52 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-12 13:50:58 -0800
commitd8b67f49d7f8ae291cd4fa901b2d3767137704e7 (patch)
tree2d039015afcd03433da0dd8860a83ce3ce2a65cf /payload_generator/extent_utils.h
parent06c6d088b89656a120d40c4b578200c87af5c4c8 (diff)
update_engine: Remove the duplicate BlocksInExtents
This patch removes the duplicate BlocksInExtents from extent_utils.h and fixes the remainder of the code to reflect this change. BUG=none TEST=unittests pass; Change-Id: I76f5106f75072b20cd8f41f081b2f2b07aeac9a8 Reviewed-on: https://chromium-review.googlesource.com/812009 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Alex Deymo <deymo@google.com> Reviewed-by: Sen Jiang <senj@chromium.org>
Diffstat (limited to 'payload_generator/extent_utils.h')
-rw-r--r--payload_generator/extent_utils.h21
1 files changed, 1 insertions, 20 deletions
diff --git a/payload_generator/extent_utils.h b/payload_generator/extent_utils.h
index 3e45264b..f5fbb0e0 100644
--- a/payload_generator/extent_utils.h
+++ b/payload_generator/extent_utils.h
@@ -32,31 +32,12 @@ namespace chromeos_update_engine {
// into an arbitrary place in the extents.
void AppendBlockToExtents(std::vector<Extent>* extents, uint64_t block);
-// Get/SetElement are intentionally overloaded so that templated functions
-// can accept either type of collection of Extents.
-Extent GetElement(const std::vector<Extent>& collection, size_t index);
-Extent GetElement(
- const google::protobuf::RepeatedPtrField<Extent>& collection,
- size_t index);
-
-// Return the total number of blocks in a collection (vector or
-// RepeatedPtrField) of Extents.
-template<typename T>
-uint64_t BlocksInExtents(const T& collection) {
- uint64_t ret = 0;
- for (size_t i = 0; i < static_cast<size_t>(collection.size()); ++i) {
- ret += GetElement(collection, i).num_blocks();
- }
- return ret;
-}
-
// Takes a collection (vector or RepeatedPtrField) of Extent and
// returns a vector of the blocks referenced, in order.
template<typename T>
std::vector<uint64_t> ExpandExtents(const T& extents) {
std::vector<uint64_t> ret;
- for (size_t i = 0, e = static_cast<size_t>(extents.size()); i != e; ++i) {
- const Extent extent = GetElement(extents, i);
+ for (const auto& extent : extents) {
if (extent.start_block() == kSparseHole) {
ret.resize(ret.size() + extent.num_blocks(), kSparseHole);
} else {