Convert some for loops over to range-based for
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 16:19:06 +0000 (16:19 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 16:19:06 +0000 (16:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126752

Reviewed by Antti Koivisto.

* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources):
* loader/appcache/ApplicationCache.cpp:
(WebCore::ApplicationCache::clearStorageID):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
(WebCore::ApplicationCacheGroup::clearStorageID):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::fillResourceList):
* loader/appcache/ApplicationCacheResource.cpp:
(WebCore::ApplicationCacheResource::estimatedSizeInStorage):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::cacheGroupForURL):
* loader/archive/ArchiveFactory.cpp:
(WebCore::ArchiveFactory::registerKnownArchiveMIMETypes):
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::styleAvailable):
(WebCore::AnimationControllerPrivate::startTimeResponse):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161634 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
Source/WebCore/loader/appcache/ApplicationCache.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
Source/WebCore/loader/appcache/ApplicationCacheResource.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/loader/archive/ArchiveFactory.cpp
Source/WebCore/page/animation/AnimationController.cpp

index a52dccd..f7460fa 100644 (file)
@@ -1,5 +1,31 @@
 2014-01-10  Anders Carlsson  <andersca@apple.com>
 
+        Convert some for loops over to range-based for
+        https://bugs.webkit.org/show_bug.cgi?id=126752
+
+        Reviewed by Antti Koivisto.
+
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources):
+        * loader/appcache/ApplicationCache.cpp:
+        (WebCore::ApplicationCache::clearStorageID):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
+        (WebCore::ApplicationCacheGroup::clearStorageID):
+        * loader/appcache/ApplicationCacheHost.cpp:
+        (WebCore::ApplicationCacheHost::fillResourceList):
+        * loader/appcache/ApplicationCacheResource.cpp:
+        (WebCore::ApplicationCacheResource::estimatedSizeInStorage):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::cacheGroupForURL):
+        * loader/archive/ArchiveFactory.cpp:
+        (WebCore::ArchiveFactory::registerKnownArchiveMIMETypes):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::styleAvailable):
+        (WebCore::AnimationControllerPrivate::startTimeResponse):
+
+2014-01-10  Anders Carlsson  <andersca@apple.com>
+
         Tighten up two functions in the inspector code
         https://bugs.webkit.org/show_bug.cgi?id=126751
 
index 83557f9..48cb417 100644 (file)
@@ -166,10 +166,8 @@ PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::ApplicationCach
 {
     RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::ApplicationCache::ApplicationCacheResource>> resources = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::ApplicationCache::ApplicationCacheResource>::create();
 
-    ApplicationCacheHost::ResourceInfoList::const_iterator end = applicationCacheResources.end();
-    ApplicationCacheHost::ResourceInfoList::const_iterator it = applicationCacheResources.begin();
-    for (int i = 0; it != end; ++it, i++)
-        resources->addItem(buildObjectForApplicationCacheResource(*it));
+    for (const auto& resourceInfo : applicationCacheResources)
+        resources->addItem(buildObjectForApplicationCacheResource(resourceInfo));
 
     return resources;
 }
index e11fb79..21e8343 100644 (file)
@@ -186,9 +186,8 @@ void ApplicationCache::clearStorageID()
 {
     m_storageID = 0;
     
-    ResourceMap::const_iterator end = m_resources.end();
-    for (ResourceMap::const_iterator it = m_resources.begin(); it != end; ++it)
-        it->value->clearStorageID();
+    for (const auto& resource : m_resources.values())
+        resource->clearStorageID();
 }
     
 void ApplicationCache::deleteCacheForOrigin(SecurityOrigin* origin)
index 5ba9f62..ad014a7 100644 (file)
@@ -781,17 +781,15 @@ void ApplicationCacheGroup::didFinishLoadingManifest()
     ASSERT(m_pendingEntries.isEmpty());
 
     if (isUpgradeAttempt) {
-        ApplicationCache::ResourceMap::const_iterator end = m_newestCache->end();
-        for (ApplicationCache::ResourceMap::const_iterator it = m_newestCache->begin(); it != end; ++it) {
-            unsigned type = it->value->type();
+        for (const auto& urlAndResource : *m_newestCache) {
+            unsigned type = urlAndResource.value->type();
             if (type & ApplicationCacheResource::Master)
-                addEntry(it->key, type);
+                addEntry(urlAndResource.key, type);
         }
     }
     
-    HashSet<String>::const_iterator end = manifest.explicitURLs.end();
-    for (HashSet<String>::const_iterator it = manifest.explicitURLs.begin(); it != end; ++it)
-        addEntry(*it, ApplicationCacheResource::Explicit);
+    for (const auto& explicitURL : manifest.explicitURLs)
+        addEntry(explicitURL, ApplicationCacheResource::Explicit);
 
     size_t fallbackCount = manifest.fallbackURLs.size();
     for (size_t i = 0; i  < fallbackCount; ++i)
@@ -1179,9 +1177,8 @@ void ApplicationCacheGroup::clearStorageID()
 {
     m_storageID = 0;
     
-    HashSet<ApplicationCache*>::const_iterator end = m_caches.end();
-    for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it != end; ++it)
-        (*it)->clearStorageID();
+    for (const auto& cache : m_caches)
+        cache->clearStorageID();
 }
 
 }
index 433bf26..9cc3f8d 100644 (file)
@@ -285,10 +285,9 @@ void ApplicationCacheHost::fillResourceList(ResourceInfoList* resources)
     ApplicationCache* cache = applicationCache();
     if (!cache || !cache->isComplete())
         return;
-     
-    ApplicationCache::ResourceMap::const_iterator end = cache->end();
-    for (ApplicationCache::ResourceMap::const_iterator it = cache->begin(); it != end; ++it) {
-        RefPtr<ApplicationCacheResource> resource = it->value;
+    
+    for (const auto& urlAndResource : *cache) {
+        RefPtr<ApplicationCacheResource> resource = urlAndResource.value;
         unsigned type = resource->type();
         bool isMaster   = type & ApplicationCacheResource::Master;
         bool isManifest = type & ApplicationCacheResource::Manifest;
index 4fcb8f2..2d9a8f1 100644 (file)
@@ -52,9 +52,8 @@ int64_t ApplicationCacheResource::estimatedSizeInStorage()
     if (data())
         m_estimatedSizeInStorage = data()->size();
 
-    HTTPHeaderMap::const_iterator end = response().httpHeaderFields().end();
-    for (HTTPHeaderMap::const_iterator it = response().httpHeaderFields().begin(); it != end; ++it)
-        m_estimatedSizeInStorage += (it->key.length() + it->value.length() + 2) * sizeof(UChar);
+    for (const auto& headerField : response().httpHeaderFields())
+        m_estimatedSizeInStorage += (headerField.key.length() + headerField.value.length() + 2) * sizeof(UChar);
 
     m_estimatedSizeInStorage += url().string().length() * sizeof(UChar);
     m_estimatedSizeInStorage += sizeof(int); // response().m_httpStatusCode
index cf915a4..b66fb8f 100644 (file)
@@ -210,10 +210,7 @@ ApplicationCacheGroup* ApplicationCacheStorage::cacheGroupForURL(const URL& url)
         return 0;
 
     // Check if a cache already exists in memory.
-    CacheGroupMap::const_iterator end = m_cachesInMemory.end();
-    for (CacheGroupMap::const_iterator it = m_cachesInMemory.begin(); it != end; ++it) {
-        ApplicationCacheGroup* group = it->value;
-
+    for (const auto& group : m_cachesInMemory.values()) {
         ASSERT(!group->isObsolete());
 
         if (!protocolHostAndPortAreEqual(url, group->manifestURL()))
index d775bc9..adbd5da 100644 (file)
@@ -91,11 +91,9 @@ PassRefPtr<Archive> ArchiveFactory::create(const URL& url, SharedBuffer* data, c
 void ArchiveFactory::registerKnownArchiveMIMETypes()
 {
     HashSet<String>& mimeTypes = MIMETypeRegistry::getSupportedNonImageMIMETypes();
-    ArchiveMIMETypesMap::iterator i = archiveMIMETypes().begin();
-    ArchiveMIMETypesMap::iterator end = archiveMIMETypes().end();
-
-    for (; i != end; ++i)
-        mimeTypes.add(i->key);
+    
+    for (const auto& mimeType : archiveMIMETypes().keys())
+        mimeTypes.add(mimeType);
 }
 
 }
index 1f6ad4e..831c862 100644 (file)
@@ -405,10 +405,8 @@ void AnimationControllerPrivate::removeFromAnimationsWaitingForStyle(AnimationBa
 void AnimationControllerPrivate::styleAvailable()
 {
     // Go through list of waiters and send them on their way
-    WaitingAnimationsSet::const_iterator it = m_animationsWaitingForStyle.begin();
-    WaitingAnimationsSet::const_iterator end = m_animationsWaitingForStyle.end();
-    for (; it != end; ++it)
-        (*it)->styleAvailable();
+    for (const auto& waitingAnimation : m_animationsWaitingForStyle)
+        waitingAnimation->styleAvailable();
 
     m_animationsWaitingForStyle.clear();
 }
@@ -451,10 +449,8 @@ void AnimationControllerPrivate::startTimeResponse(double time)
 {
     // Go through list of waiters and send them on their way
 
-    WaitingAnimationsSet::const_iterator it = m_animationsWaitingForStartTimeResponse.begin();
-    WaitingAnimationsSet::const_iterator end = m_animationsWaitingForStartTimeResponse.end();
-    for (; it != end; ++it)
-        (*it)->onAnimationStartResponse(time);
+    for (const auto& animation : m_animationsWaitingForStartTimeResponse)
+        animation->onAnimationStartResponse(time);
     
     m_animationsWaitingForStartTimeResponse.clear();
     m_waitingForAsyncStartNotification = false;