Bug 1317637 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in gfx/. draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 15 Nov 2016 10:55:49 +0200
changeset 439548 bfc68d2fc99267ef295750fd32176e1212027367
parent 439375 79feeed4293336089590320a9f30a813fade8e3c
child 439549 76ed8649d8c3c32f8bfd03d4ae89b90a8a39a0aa
push id36039
push userbmo:bpostelnicu@mozilla.com
push dateWed, 16 Nov 2016 08:32:40 +0000
bugs1317637
milestone53.0a1
Bug 1317637 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in gfx/. MozReview-Commit-ID: Dd6426wCbMg
gfx/2d/DrawTargetSkia.cpp
gfx/layers/PersistentBufferProvider.cpp
gfx/thebes/gfxPlatform.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -188,18 +188,17 @@ VerifyRGBXCorners(uint8_t* aData, const 
   const int bottomLeft = aStride * height - aStride;
 
   // Lastly the center pixel
   int middleRowHeight = height / 2;
   int middleRowWidth = (width / 2) * pixelSize;
   const int middle = aStride * middleRowHeight + middleRowWidth;
 
   const int offsets[] = { topLeft, topRight, bottomRight, bottomLeft, middle };
-  for (size_t i = 0; i < MOZ_ARRAY_LENGTH(offsets); i++) {
-    int offset = offsets[i];
+  for (int offset : offsets) {
     if (aData[offset + kARGBAlphaOffset] != 0xFF) {
         int row = offset / aStride;
         int column = (offset % aStride) / pixelSize;
         gfxCriticalError() << "RGBX corner pixel at (" << column << "," << row << ") in "
                            << width << "x" << height << " surface is not opaque: "
                            << int(aData[offset]) << ","
                            << int(aData[offset+1]) << ","
                            << int(aData[offset+2]) << ","
--- a/gfx/layers/PersistentBufferProvider.cpp
+++ b/gfx/layers/PersistentBufferProvider.cpp
@@ -425,18 +425,18 @@ PersistentBufferProviderShared::NotifyIn
 }
 
 void
 PersistentBufferProviderShared::Destroy()
 {
   mSnapshot = nullptr;
   mDrawTarget = nullptr;
 
-  for (uint32_t i = 0; i < mTextures.length(); ++i) {
-    TextureClient* texture = mTextures[i];
+  for (auto& mTexture : mTextures) {
+    TextureClient* texture = mTexture;
     if (texture && texture->IsLocked()) {
       MOZ_ASSERT(false);
       texture->Unlock();
     }
   }
 
   mTextures.clear();
 }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -284,18 +284,18 @@ void CrashStatsLogForwarder::UpdateCrash
   case GeckoProcessType_GPU:
     logAnnotation = "|[G";
     break;
   default:
     logAnnotation = "|[X";
     break;
   }
 
-  for (LoggingRecord::iterator it = mBuffer.begin(); it != mBuffer.end(); ++it) {
-    message << logAnnotation << Get<0>(*it) << "]" << Get<1>(*it) << " (t=" << Get<2>(*it) << ") ";
+  for (auto& it : mBuffer) {
+    message << logAnnotation << Get<0>(it) << "]" << Get<1>(it) << " (t=" << Get<2>(it) << ") ";
   }
 
 #ifdef MOZ_CRASHREPORTER
   nsCString reportString(message.str().c_str());
   nsresult annotated = CrashReporter::AnnotateCrashReport(mCrashCriticalKey, reportString);
 #else
   nsresult annotated = NS_ERROR_NOT_IMPLEMENTED;
 #endif