Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2893)

Unified Diff: cc/tile_manager.cc

Issue 12207146: changing std::vector to std::set for all_tiles_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: making iterator const Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tile_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tile_manager.cc
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 888a0f71dba3b0dcfe84d2c25ca66ac98cea464d..9f761bc26985b951d6571da27f889c9a19067de1 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -209,7 +209,7 @@ void TileManager::SetGlobalState(
}
void TileManager::RegisterTile(Tile* tile) {
- all_tiles_.push_back(tile);
+ all_tiles_.insert(tile);
const ManagedTileState& mts = tile->managed_state();
for (int i = 0; i < NUM_TREES; ++i)
@@ -240,18 +240,13 @@ void TileManager::UnregisterTile(Tile* tile) {
break;
}
}
- for (TileVector::iterator it = all_tiles_.begin();
- it != all_tiles_.end(); it++) {
- if (*it == tile) {
- const ManagedTileState& mts = tile->managed_state();
- for (int i = 0; i < NUM_TREES; ++i)
- --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]];
- FreeResourcesForTile(tile);
- all_tiles_.erase(it);
- return;
- }
- }
- DCHECK(false) << "Could not find tile version.";
+ TileSet::iterator it = all_tiles_.find(tile);
+ DCHECK(it != all_tiles_.end());
+ const ManagedTileState& mts = tile->managed_state();
+ for (int i = 0; i < NUM_TREES; ++i)
+ --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]];
+ FreeResourcesForTile(tile);
+ all_tiles_.erase(it);
}
class BinComparator {
@@ -322,7 +317,7 @@ void TileManager::ManageTiles() {
live_or_allocated_tiles_.clear();
// For each tree, bin into different categories of tiles.
- for (TileVector::iterator it = all_tiles_.begin();
+ for (TileSet::iterator it = all_tiles_.begin();
it != all_tiles_.end(); ++it) {
Tile* tile = *it;
ManagedTileState& mts = tile->managed_state();
@@ -469,8 +464,10 @@ scoped_ptr<base::Value> TileManager::BasicStateAsValue() const {
}
scoped_ptr<base::Value> TileManager::AllTilesAsValue() const {
scoped_ptr<base::ListValue> state(new base::ListValue());
- for (size_t i = 0; i < all_tiles_.size(); i++)
- state->Append(all_tiles_[i]->AsValue().release());
+ for (TileSet::const_iterator it = all_tiles_.begin();
+ it != all_tiles_.end(); it++) {
+ state->Append((*it)->AsValue().release());
+ }
return state.PassAs<base::Value>();
}
« no previous file with comments | « cc/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698