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

Unified Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2381613003: Rewrite the while loop in DrawingBuffer::createOrRecycleBitmap (Closed)
Patch Set: changed to std::move_if Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
index 4c091582de49074dcaf4289d1c512f876f1bd962..42b5a7a29f5129787aed231136db486b19b53a21 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -249,13 +249,13 @@ void DrawingBuffer::freeRecycledMailboxes()
std::unique_ptr<cc::SharedBitmap> DrawingBuffer::createOrRecycleBitmap()
{
- size_t i = 0;
- while (i < m_recycledBitmaps.size()) {
- if (m_recycledBitmaps[i].size != m_size)
- m_recycledBitmaps.remove(i); // Removed this position so iterate on it again.
- else
- ++i;
- }
+ auto it = std::remove_if(m_recycledBitmaps.begin(), m_recycledBitmaps.end(),
+ [this](const RecycledBitmap& bitmap)
+ {
+ return bitmap.size != m_size;
+ });
+ m_recycledBitmaps.shrink(it - m_recycledBitmaps.begin());
+
if (!m_recycledBitmaps.isEmpty()) {
RecycledBitmap recycled = std::move(m_recycledBitmaps.last());
m_recycledBitmaps.removeLast();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698