Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "update_engine/graph_utils.h" | |
| 6 #include "base/basictypes.h" | |
| 7 | |
| 8 using std::vector; | |
| 9 | |
| 10 namespace chromeos_update_engine { | |
| 11 | |
| 12 uint64 EdgeWeight(const Graph& graph, const Edge& edge) { | |
| 13 uint64 ret = 0; | |
|
Daniel Erat
2010/02/05 17:55:19
s/ret/weight/
adlr
2010/02/22 23:27:31
Done.
| |
| 14 const vector<Extent>& extents = | |
| 15 graph[edge.first].out_edges.find(edge.second)->second.extents; | |
| 16 for (vector<Extent>::const_iterator it = extents.begin(); | |
| 17 it != extents.end(); ++it) { | |
| 18 ret += it->num_blocks(); | |
| 19 } | |
| 20 return ret; | |
| 21 } | |
| 22 | |
| 23 void AppendBlockToExtents(uint64 block, vector<Extent>* extents) { | |
|
Daniel Erat
2010/02/05 17:55:19
i think that the opposite parameter order is more
adlr
2010/02/22 23:27:31
Done.
| |
| 24 if (!extents->empty()) { | |
| 25 Extent& extent = extents->back(); | |
|
Daniel Erat
2010/02/05 17:55:19
you're just checking the last extent here. does t
adlr
2010/02/22 23:27:31
no, blocks do not need to be appended in order. I
| |
| 26 if (extent.start_block() + extent.num_blocks() == block) { | |
| 27 extent.set_num_blocks(extent.num_blocks() + 1); | |
| 28 return; | |
| 29 } | |
| 30 } | |
| 31 Extent new_extent; | |
| 32 new_extent.set_start_block(block); | |
| 33 new_extent.set_num_blocks(1); | |
| 34 extents->push_back(new_extent); | |
| 35 } | |
| 36 | |
| 37 } // namespace chromeos_update_engine | |
| OLD | NEW |