Commit 188fa89f authored by andersca@apple.com's avatar andersca@apple.com

Begin cleaning up handling of ImmutableArray vectors

https://bugs.webkit.org/show_bug.cgi?id=124208

Reviewed by Andreas Kling.

Use range based for to iterate the loops. Use reserveInitialCapacity + uncheckedAppend
when appending vector elements.

* Shared/SecurityOriginData.cpp:
(WebKit::performAPICallbackWithSecurityOriginDataVector):
* Shared/WebArchive.cpp:
(WebKit::WebArchive::subresources):
(WebKit::WebArchive::subframeArchives):
* Shared/WebContextMenuItem.cpp:
(WebKit::WebContextMenuItem::submenuItemsAsImmutableArray):
* Shared/WebOpenPanelParameters.cpp:
(WebKit::WebOpenPanelParameters::acceptMIMETypes):
(WebKit::WebOpenPanelParameters::selectedFileNames):
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(WKContextGetInfoForInstalledPlugIns):
* UIProcess/Plugins/WebPluginSiteDataManager.cpp:
(WebKit::WebPluginSiteDataManager::didGetSitesWithData):
* UIProcess/StatisticsRequest.cpp:
(WebKit::StatisticsRequest::completedRequest):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::pluginInfoStoreDidLoadPlugins):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
* UIProcess/WebDatabaseManagerProxy.cpp:
(WebKit::WebDatabaseManagerProxy::didGetDatabasesByOrigin):
(WebKit::WebDatabaseManagerProxy::didGetDatabaseOrigins):
* UIProcess/WebMediaCacheManagerProxy.cpp:
(WebKit::WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache):
* UIProcess/WebPageContextMenuClient.cpp:
(WebKit::WebPageContextMenuClient::showContextMenu):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::relatedPages):
(WebKit::WebPageProxy::didFindStringMatches):
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::originsWithApplicationCache):
* WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp:
(WebKit::InjectedBundleBackForwardListItem::children):
* WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
(WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
(WebKit::InjectedBundlePageLoaderClient::featuresUsedInPage):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::trackedRepaintRects):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fc6d4eae
2013-11-12 Anders Carlsson <andersca@apple.com>
Begin cleaning up handling of ImmutableArray vectors
https://bugs.webkit.org/show_bug.cgi?id=124208
Reviewed by Andreas Kling.
Use range based for to iterate the loops. Use reserveInitialCapacity + uncheckedAppend
when appending vector elements.
* Shared/SecurityOriginData.cpp:
(WebKit::performAPICallbackWithSecurityOriginDataVector):
* Shared/WebArchive.cpp:
(WebKit::WebArchive::subresources):
(WebKit::WebArchive::subframeArchives):
* Shared/WebContextMenuItem.cpp:
(WebKit::WebContextMenuItem::submenuItemsAsImmutableArray):
* Shared/WebOpenPanelParameters.cpp:
(WebKit::WebOpenPanelParameters::acceptMIMETypes):
(WebKit::WebOpenPanelParameters::selectedFileNames):
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(WKContextGetInfoForInstalledPlugIns):
* UIProcess/Plugins/WebPluginSiteDataManager.cpp:
(WebKit::WebPluginSiteDataManager::didGetSitesWithData):
* UIProcess/StatisticsRequest.cpp:
(WebKit::StatisticsRequest::completedRequest):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::pluginInfoStoreDidLoadPlugins):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
* UIProcess/WebDatabaseManagerProxy.cpp:
(WebKit::WebDatabaseManagerProxy::didGetDatabasesByOrigin):
(WebKit::WebDatabaseManagerProxy::didGetDatabaseOrigins):
* UIProcess/WebMediaCacheManagerProxy.cpp:
(WebKit::WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache):
* UIProcess/WebPageContextMenuClient.cpp:
(WebKit::WebPageContextMenuClient::showContextMenu):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::relatedPages):
(WebKit::WebPageProxy::didFindStringMatches):
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::originsWithApplicationCache):
* WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp:
(WebKit::InjectedBundleBackForwardListItem::children):
* WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
(WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
(WebKit::InjectedBundlePageLoaderClient::featuresUsedInPage):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::trackedRepaintRects):
2013-11-12 Csaba Osztrogonác <ossy@webkit.org>
One more URTBF after r159108.
......
......@@ -77,16 +77,14 @@ void performAPICallbackWithSecurityOriginDataVector(const Vector<SecurityOriginD
return;
}
size_t originDataCount = originDatas.size();
Vector<RefPtr<APIObject>> securityOrigins;
securityOrigins.reserveCapacity(originDataCount);
securityOrigins.reserveInitialCapacity(originDatas.size());
for (size_t i = 0; i < originDataCount; ++i) {
SecurityOriginData originData = originDatas[i];
for (const auto& originData : originDatas) {
RefPtr<APIObject> origin = WebSecurityOrigin::create(originData.protocol, originData.host, originData.port);
if (!origin)
continue;
securityOrigins.uncheckedAppend(origin);
securityOrigins.uncheckedAppend(std::move(origin));
}
callback->performCallbackWithReturnValue(ImmutableArray::adopt(securityOrigins).get());
......
......@@ -108,9 +108,10 @@ ImmutableArray* WebArchive::subresources()
{
if (!m_cachedSubresources) {
Vector<RefPtr<APIObject>> subresources;
subresources.reserveCapacity(m_legacyWebArchive->subresources().size());
for (unsigned i = 0; i < m_legacyWebArchive->subresources().size(); ++i)
subresources.append(WebArchiveResource::create(m_legacyWebArchive->subresources()[i].get()));
subresources.reserveInitialCapacity(m_legacyWebArchive->subresources().size());
for (const auto& subresource : m_legacyWebArchive->subresources())
subresources.uncheckedAppend(WebArchiveResource::create(subresource));
m_cachedSubresources = ImmutableArray::adopt(subresources);
}
......@@ -122,9 +123,10 @@ ImmutableArray* WebArchive::subframeArchives()
{
if (!m_cachedSubframeArchives) {
Vector<RefPtr<APIObject>> subframeWebArchives;
subframeWebArchives.reserveCapacity(m_legacyWebArchive->subframeArchives().size());
for (unsigned i = 0; i < m_legacyWebArchive->subframeArchives().size(); ++i)
subframeWebArchives.append(WebArchive::create(static_cast<LegacyWebArchive*>(m_legacyWebArchive->subframeArchives()[i].get())));
subframeWebArchives.reserveInitialCapacity(m_legacyWebArchive->subframeArchives().size());
for (const auto& subframeArchive : m_legacyWebArchive->subframeArchives())
subframeWebArchives.uncheckedAppend(WebArchive::create(static_cast<LegacyWebArchive*>(subframeArchive.get())));
m_cachedSubframeArchives = ImmutableArray::adopt(subframeWebArchives);
}
......
......@@ -66,16 +66,13 @@ PassRefPtr<ImmutableArray> WebContextMenuItem::submenuItemsAsImmutableArray() co
if (m_webContextMenuItemData.type() != WebCore::SubmenuType)
return ImmutableArray::create();
const Vector<WebContextMenuItemData>& submenuVector(m_webContextMenuItemData.submenu());
unsigned size = submenuVector.size();
Vector<RefPtr<APIObject>> result;
result.reserveCapacity(size);
for (unsigned i = 0; i < size; ++i)
result.append(WebContextMenuItem::create(submenuVector[i]));
return ImmutableArray::adopt(result);
Vector<RefPtr<APIObject>> submenuItems;
submenuItems.reserveInitialCapacity(m_webContextMenuItemData.submenu().size());
for (const auto& item : m_webContextMenuItemData.submenu())
submenuItems.uncheckedAppend(WebContextMenuItem::create(item));
return ImmutableArray::adopt(submenuItems);
}
APIObject* WebContextMenuItem::userData() const
......
......@@ -51,13 +51,12 @@ WebOpenPanelParameters::~WebOpenPanelParameters()
PassRefPtr<ImmutableArray> WebOpenPanelParameters::acceptMIMETypes() const
{
size_t size = m_settings.acceptMIMETypes.size();
Vector<RefPtr<APIObject>> vector;
vector.reserveInitialCapacity(size);
for (size_t i = 0; i < size; ++i)
vector.uncheckedAppend(WebString::create(m_settings.acceptMIMETypes[i]));
vector.reserveInitialCapacity(m_settings.acceptMIMETypes.size());
for (const auto& mimeType : m_settings.acceptMIMETypes)
vector.uncheckedAppend(WebString::create(mimeType));
return ImmutableArray::adopt(vector);
}
......@@ -70,15 +69,13 @@ String WebOpenPanelParameters::capture() const
PassRefPtr<ImmutableArray> WebOpenPanelParameters::selectedFileNames() const
{
size_t size = m_settings.selectedFiles.size();
Vector<RefPtr<APIObject>> vector;
vector.reserveInitialCapacity(size);
vector.reserveInitialCapacity(m_settings.selectedFiles.size());
for (const auto& selectedFile : m_settings.selectedFiles)
vector.uncheckedAppend(WebString::create(selectedFile));
for (size_t i = 0; i < size; ++i)
vector.uncheckedAppend(WebString::create(m_settings.selectedFiles[i]));
return ImmutableArray::adopt(vector);
}
} // namespace WebCore
......@@ -74,8 +74,10 @@ void WKContextGetInfoForInstalledPlugIns(WKContextRef contextRef, WKContextGetIn
Vector<PluginModuleInfo> plugins = toImpl(contextRef)->pluginInfoStore().plugins();
Vector<RefPtr<APIObject>> pluginInfoDictionaries;
pluginInfoDictionaries.reserveInitialCapacity(plugins.size());
for (const auto& plugin: plugins)
pluginInfoDictionaries.append(createPluginInformationDictionary(plugin));
pluginInfoDictionaries.uncheckedAppend(createPluginInformationDictionary(plugin));
RefPtr<ImmutableArray> array = ImmutableArray::adopt(pluginInfoDictionaries);
......
......@@ -165,13 +165,13 @@ void WebPluginSiteDataManager::didGetSitesWithData(const Vector<String>& sites,
return;
}
Vector<RefPtr<APIObject>> sitesWK(sites.size());
Vector<RefPtr<APIObject>> sitesArray;
sitesArray.reserveInitialCapacity(sites.size());
for (size_t i = 0; i < sites.size(); ++i)
sitesWK[i] = WebString::create(sites[i]);
for (const auto& site : sites)
sitesArray.uncheckedAppend(WebString::create(site));
RefPtr<ImmutableArray> resultArray = ImmutableArray::adopt(sitesWK);
callback->performCallbackWithReturnValue(resultArray.get());
callback->performCallbackWithReturnValue(ImmutableArray::adopt(sitesArray).get());
}
void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback> prpCallback)
......
......@@ -83,13 +83,15 @@ void StatisticsRequest::completedRequest(uint64_t requestID, const StatisticsDat
m_responseDictionary->set("JavaScriptProtectedObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptProtectedObjectTypeCounts).get());
if (!data.javaScriptObjectTypeCounts.isEmpty())
m_responseDictionary->set("JavaScriptObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptObjectTypeCounts).get());
size_t cacheStatisticsCount = data.webCoreCacheStatistics.size();
if (cacheStatisticsCount) {
Vector<RefPtr<APIObject>> cacheStatisticsVector(cacheStatisticsCount);
for (size_t i = 0; i < cacheStatisticsCount; ++i)
cacheStatisticsVector[i] = createDictionaryFromHashMap(data.webCoreCacheStatistics[i]);
m_responseDictionary->set("WebCoreCacheStatistics", ImmutableArray::adopt(cacheStatisticsVector).get());
if (!data.webCoreCacheStatistics.isEmpty()) {
Vector<RefPtr<APIObject>> cacheStatistics;
cacheStatistics.reserveInitialCapacity(data.webCoreCacheStatistics.size());
for (const auto& statistic : data.webCoreCacheStatistics)
cacheStatistics.uncheckedAppend(createDictionaryFromHashMap(statistic));
m_responseDictionary->set("WebCoreCacheStatistics", ImmutableArray::adopt(cacheStatistics).get());
}
if (m_outstandingRequests.isEmpty()) {
......
......@@ -1256,29 +1256,33 @@ void WebContext::pluginInfoStoreDidLoadPlugins(PluginInfoStore* store)
#endif
ASSERT(store == &m_pluginInfoStore);
Vector<RefPtr<APIObject>> pluginArray;
Vector<PluginModuleInfo> pluginModules = m_pluginInfoStore.plugins();
Vector<PluginModuleInfo> plugins = m_pluginInfoStore.plugins();
for (size_t i = 0; i < plugins.size(); ++i) {
PluginModuleInfo& plugin = plugins[i];
Vector<RefPtr<APIObject>> plugins;
plugins.reserveInitialCapacity(pluginModules.size());
for (const auto& pluginModule : pluginModules) {
ImmutableDictionary::MapType map;
map.set(ASCIILiteral("path"), WebString::create(plugin.path));
map.set(ASCIILiteral("name"), WebString::create(plugin.info.name));
map.set(ASCIILiteral("file"), WebString::create(plugin.info.file));
map.set(ASCIILiteral("desc"), WebString::create(plugin.info.desc));
Vector<RefPtr<APIObject>> mimeArray;
for (size_t j = 0; j < plugin.info.mimes.size(); ++j)
mimeArray.append(WebString::create(plugin.info.mimes[j].type));
map.set(ASCIILiteral("mimes"), ImmutableArray::adopt(mimeArray));
map.set(ASCIILiteral("path"), WebString::create(pluginModule.path));
map.set(ASCIILiteral("name"), WebString::create(pluginModule.info.name));
map.set(ASCIILiteral("file"), WebString::create(pluginModule.info.file));
map.set(ASCIILiteral("desc"), WebString::create(pluginModule.info.desc));
Vector<RefPtr<APIObject>> mimeTypes;
mimeTypes.reserveInitialCapacity(pluginModule.info.mimes.size());
for (const auto& mimeClassInfo : pluginModule.info.mimes)
mimeTypes.uncheckedAppend(WebString::create(mimeClassInfo.type));
map.set(ASCIILiteral("mimes"), ImmutableArray::adopt(mimeTypes));
#if PLATFORM(MAC)
map.set(ASCIILiteral("bundleId"), WebString::create(plugin.bundleIdentifier));
map.set(ASCIILiteral("version"), WebString::create(plugin.versionString));
map.set(ASCIILiteral("bundleId"), WebString::create(pluginModule.bundleIdentifier));
map.set(ASCIILiteral("version"), WebString::create(pluginModule.versionString));
#endif
pluginArray.append(ImmutableDictionary::adopt(map));
plugins.uncheckedAppend(ImmutableDictionary::adopt(map));
}
m_client.plugInInformationBecameAvailable(this, ImmutableArray::adopt(pluginArray).get());
m_client.plugInInformationBecameAvailable(this, ImmutableArray::adopt(plugins).get());
}
#endif
......
......@@ -107,7 +107,7 @@ void WebCookieManagerProxy::getHostnamesWithCookies(PassRefPtr<ArrayCallback> pr
context()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID));
}
void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnameList, uint64_t callbackID)
void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnames, uint64_t callbackID)
{
RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
if (!callback) {
......@@ -115,13 +115,13 @@ void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hos
return;
}
size_t hostnameCount = hostnameList.size();
Vector<RefPtr<APIObject>> hostnames(hostnameCount);
Vector<RefPtr<APIObject>> hostnameStrings;
hostnameStrings.reserveInitialCapacity(hostnames.size());
for (size_t i = 0; i < hostnameCount; ++i)
hostnames[i] = WebString::create(hostnameList[i]);
for (const auto& hostname : hostnames)
hostnameStrings.uncheckedAppend(WebString::create(hostname));
callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnameStrings).get());
}
void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname)
......
......@@ -156,26 +156,24 @@ void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndData
return;
}
size_t originAndDatabasesCount = originAndDatabasesVector.size();
Vector<RefPtr<APIObject>> result(originAndDatabasesCount);
Vector<RefPtr<APIObject>> result;
result.reserveInitialCapacity(originAndDatabasesVector.size());
for (size_t i = 0; i < originAndDatabasesCount; ++i) {
const OriginAndDatabases& originAndDatabases = originAndDatabasesVector[i];
for (const auto& originAndDatabases : originAndDatabasesVector) {
RefPtr<APIObject> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originAndDatabases.originIdentifier);
size_t databasesCount = originAndDatabases.databases.size();
Vector<RefPtr<APIObject>> databases(databasesCount);
for (size_t j = 0; j < databasesCount; ++j) {
const DatabaseDetails& details = originAndDatabases.databases[i];
Vector<RefPtr<APIObject>> databases;
databases.reserveInitialCapacity(originAndDatabases.databases.size());
for (const auto& databaseDetails : originAndDatabases.databases) {
HashMap<String, RefPtr<APIObject>> detailsMap;
detailsMap.set(databaseDetailsNameKey(), WebString::create(details.name()));
detailsMap.set(databaseDetailsDisplayNameKey(), WebString::create(details.displayName()));
detailsMap.set(databaseDetailsExpectedUsageKey(), WebUInt64::create(details.expectedUsage()));
detailsMap.set(databaseDetailsCurrentUsageKey(), WebUInt64::create(details.currentUsage()));
databases.append(ImmutableDictionary::adopt(detailsMap));
detailsMap.set(databaseDetailsNameKey(), WebString::create(databaseDetails.name()));
detailsMap.set(databaseDetailsDisplayNameKey(), WebString::create(databaseDetails.displayName()));
detailsMap.set(databaseDetailsExpectedUsageKey(), WebUInt64::create(databaseDetails.expectedUsage()));
detailsMap.set(databaseDetailsCurrentUsageKey(), WebUInt64::create(databaseDetails.currentUsage()));
databases.uncheckedAppend(ImmutableDictionary::adopt(detailsMap));
}
HashMap<String, RefPtr<APIObject>> originAndDatabasesMap;
......@@ -184,11 +182,10 @@ void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndData
originAndDatabasesMap.set(originUsageKey(), WebUInt64::create(originAndDatabases.originUsage));
originAndDatabasesMap.set(databaseDetailsKey(), ImmutableArray::adopt(databases));
result.append(ImmutableDictionary::adopt(originAndDatabasesMap));
result.uncheckedAppend(ImmutableDictionary::adopt(originAndDatabasesMap));
}
RefPtr<ImmutableArray> resultArray = ImmutableArray::adopt(result);
callback->performCallbackWithReturnValue(resultArray.get());
callback->performCallbackWithReturnValue(ImmutableArray::adopt(result).get());
}
void WebDatabaseManagerProxy::getDatabaseOrigins(PassRefPtr<ArrayCallback> prpCallback)
......@@ -208,11 +205,11 @@ void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& origin
return;
}
size_t originIdentifiersCount = originIdentifiers.size();
Vector<RefPtr<APIObject>> securityOrigins(originIdentifiersCount);
Vector<RefPtr<APIObject>> securityOrigins;
securityOrigins.reserveInitialCapacity(originIdentifiers.size());
for (size_t i = 0; i < originIdentifiersCount; ++i)
securityOrigins[i] = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifiers[i]);
for (const auto& originIdentifier : originIdentifiers)
securityOrigins.uncheckedAppend(WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier));
callback->performCallbackWithReturnValue(ImmutableArray::adopt(securityOrigins).get());
}
......
......@@ -90,7 +90,7 @@ void WebMediaCacheManagerProxy::getHostnamesWithMediaCache(PassRefPtr<ArrayCallb
context()->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::GetHostnamesWithMediaCache(callbackID));
}
void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<String>& hostnameList, uint64_t callbackID)
void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<String>& hostnames, uint64_t callbackID)
{
RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
if (!callback) {
......@@ -98,13 +98,13 @@ void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<Strin
return;
}
size_t hostnameCount = hostnameList.size();
Vector<RefPtr<APIObject>> hostnames(hostnameCount);
Vector<RefPtr<APIObject>> hostnamesArray;
hostnamesArray.reserveInitialCapacity(hostnames.size());
for (size_t i = 0; i < hostnameCount; ++i)
hostnames[i] = WebString::create(hostnameList[i]);
for (const auto& hostname : hostnames)
hostnamesArray.uncheckedAppend(WebString::create(hostname));
callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnamesArray).get());
}
void WebMediaCacheManagerProxy::clearCacheForHostname(const String& hostname)
......
......@@ -98,13 +98,11 @@ bool WebPageContextMenuClient::showContextMenu(WebPageProxy* page, const WebCore
if (!m_client.showContextMenu)
return false;
unsigned size = menuItemsVector.size();
Vector<RefPtr<APIObject>> menuItems;
menuItems.reserveCapacity(size);
menuItems.reserveInitialCapacity(menuItemsVector.size());
for (unsigned i = 0; i < size; ++i)
menuItems.uncheckedAppend(WebContextMenuItem::create(menuItemsVector[i]).get());
for (const auto& menuItem : menuItemsVector)
menuItems.uncheckedAppend(WebContextMenuItem::create(menuItem));
m_client.showContextMenu(toAPI(page), toAPI(menuLocation), toAPI(ImmutableArray::adopt(menuItems).get()), m_client.clientInfo);
......
......@@ -393,10 +393,11 @@ PassRefPtr<ImmutableArray> WebPageProxy::relatedPages() const
Vector<WebPageProxy*> pages = m_process->pages();
Vector<RefPtr<APIObject>> result;
result.reserveCapacity(pages.size());
for (size_t i = 0; i < pages.size(); ++i) {
if (pages[i] != this)
result.append(pages[i]);
result.reserveInitialCapacity(pages.size());
for (const auto& page : pages) {
if (page != this)
result.uncheckedAppend(page);
}
return ImmutableArray::adopt(result);
......@@ -3039,16 +3040,16 @@ void WebPageProxy::didFindStringMatches(const String& string, Vector<Vector<WebC
Vector<RefPtr<APIObject>> matches;
matches.reserveInitialCapacity(matchRects.size());
for (size_t i = 0; i < matchRects.size(); ++i) {
const Vector<WebCore::IntRect>& rects = matchRects[i];
size_t numRects = matchRects[i].size();
for (const auto& rects : matchRects) {
Vector<RefPtr<APIObject>> apiRects;
apiRects.reserveInitialCapacity(numRects);
apiRects.reserveInitialCapacity(rects.size());
for (const auto& rect : rects)
apiRects.uncheckedAppend(WebRect::create(toAPI(rect)));
for (size_t i = 0; i < numRects; ++i)
apiRects.uncheckedAppend(WebRect::create(toAPI(rects[i])));
matches.uncheckedAppend(ImmutableArray::adopt(apiRects));
}
m_findMatchesClient.didFindStringMatches(this, string, ImmutableArray::adopt(matches).get(), firstIndexAfterSelection);
}
......
......@@ -407,14 +407,14 @@ PassRefPtr<ImmutableArray> InjectedBundle::originsWithApplicationCache()
{
HashSet<RefPtr<SecurityOrigin>> origins;
cacheStorage().getOriginsWithCache(origins);
Vector< RefPtr<APIObject>> originsVector;
HashSet<RefPtr<SecurityOrigin>>::iterator it = origins.begin();
HashSet<RefPtr<SecurityOrigin>>::iterator end = origins.end();
for ( ; it != end; ++it)
originsVector.append(WebString::create((*it)->databaseIdentifier()));
Vector<RefPtr<APIObject>> originIdentifiers;
originIdentifiers.reserveInitialCapacity(origins.size());
return ImmutableArray::adopt(originsVector);
for (const auto& origin : origins)
originIdentifiers.uncheckedAppend(WebString::create(origin->databaseIdentifier()));
return ImmutableArray::adopt(originIdentifiers);
}
int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels)
......
......@@ -34,12 +34,13 @@ namespace WebKit {
PassRefPtr<ImmutableArray> InjectedBundleBackForwardListItem::children() const
{
const HistoryItemVector& children = m_item->children();
size_t size = children.size();
Vector<RefPtr<APIObject>> vector(size);
for (size_t i = 0; i < size; ++i)
vector[i] = InjectedBundleBackForwardListItem::create(children[i]);
return ImmutableArray::adopt(vector);
Vector<RefPtr<APIObject>> children;
children.reserveInitialCapacity(m_item->children().size());
for (const auto& child : m_item->children())
children.uncheckedAppend(InjectedBundleBackForwardListItem::create(child));
return ImmutableArray::adopt(children);
}
} // namespace WebKit
......@@ -130,13 +130,11 @@ void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const
if (!m_client.didAssociateFormControls)
return;
size_t size = elements.size();
Vector<RefPtr<APIObject>> elementHandles;
elementHandles.reserveCapacity(size);
elementHandles.reserveInitialCapacity(elements.size());
for (size_t i = 0; i < size; ++i)
elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(elements[i].get()).get());
for (const auto& element : elements)
elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(element.get()));
m_client.didAssociateFormControls(toAPI(page), toAPI(ImmutableArray::adopt(elementHandles).get()), m_client.clientInfo);
}
......
......@@ -341,15 +341,13 @@ void InjectedBundlePageLoaderClient::featuresUsedInPage(WebPage* page, const Vec
if (!m_client.featuresUsedInPage)
return;
Vector<RefPtr<APIObject>> featureStringObjectsVector;
Vector<RefPtr<APIObject>> featureStrings;
featureStrings.reserveInitialCapacity(features.size());
Vector<String>::const_iterator end = features.end();
for (Vector<String>::const_iterator it = features.begin(); it != end; ++it)
featureStringObjectsVector.append(WebString::create((*it)));
for (const auto& feature : features)
featureStrings.uncheckedAppend(WebString::create(feature));
RefPtr<ImmutableArray> featureStringObjectsArray = ImmutableArray::adopt(featureStringObjectsVector);
return m_client.featuresUsedInPage(toAPI(page), toAPI(featureStringObjectsArray.get()), m_client.clientInfo);
return m_client.featuresUsedInPage(toAPI(page), toAPI(ImmutableArray::adopt(featureStrings).get()), m_client.clientInfo);
}
void InjectedBundlePageLoaderClient::willDestroyFrame(WebPage* page, WebFrame* frame)
......
......@@ -662,18 +662,13 @@ PassRefPtr<ImmutableArray> WebPage::trackedRepaintRects()
if (!view)
return ImmutableArray::create();
const Vector<IntRect>& rects = view->trackedRepaintRects();
size_t size = rects.size();
if (!size)
return ImmutableArray::create();
Vector<RefPtr<APIObject>> vector;
vector.reserveInitialCapacity(size);
Vector<RefPtr<APIObject>> repaintRects;
repaintRects.reserveInitialCapacity(view->trackedRepaintRects().size());
for (size_t i = 0; i < size; ++i)
vector.uncheckedAppend(WebRect::create(toAPI(rects[i])));
for (const auto& repaintRect : view->trackedRepaintRects())
repaintRects.uncheckedAppend(WebRect::create(toAPI(repaintRect)));
return ImmutableArray::adopt(vector);
return ImmutableArray::adopt(repaintRects);
}
PluginView* WebPage::focusedPluginViewForFrame(Frame& frame)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment