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

Unified Diff: Source/core/inspector/DOMPatchSupport.cpp

Issue 329183002: Removing "using" declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
Index: Source/core/inspector/DOMPatchSupport.cpp
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp
index e853b2fc6919aea1b499dee016d4c8eeec226cce..7f679e82f88e37ea142ff21fb2e6014430545248 100644
--- a/Source/core/inspector/DOMPatchSupport.cpp
+++ b/Source/core/inspector/DOMPatchSupport.cpp
@@ -54,8 +54,6 @@
#include "wtf/text/Base64.h"
#include "wtf/text/CString.h"
-using namespace std;
-
namespace WebCore {
struct DOMPatchSupport::Digest {
@@ -219,42 +217,42 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt
ResultMap newMap(newList.size());
ResultMap oldMap(oldList.size());
- for (size_t i = 0; i < oldMap.size(); ++i) {
+ for (std::size_t i = 0; i < oldMap.size(); ++i) {
oldMap[i].first = 0;
oldMap[i].second = 0;
}
- for (size_t i = 0; i < newMap.size(); ++i) {
+ for (std::size_t i = 0; i < newMap.size(); ++i) {
newMap[i].first = 0;
newMap[i].second = 0;
}
// Trim head and tail.
- for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[i]->m_sha1 == newList[i]->m_sha1; ++i) {
+ for (std::size_t i = 0; i < oldList.size() && i < newList.size() && oldList[i]->m_sha1 == newList[i]->m_sha1; ++i) {
oldMap[i].first = oldList[i].get();
oldMap[i].second = i;
newMap[i].first = newList[i].get();
newMap[i].second = i;
}
- for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[oldList.size() - i - 1]->m_sha1 == newList[newList.size() - i - 1]->m_sha1; ++i) {
- size_t oldIndex = oldList.size() - i - 1;
- size_t newIndex = newList.size() - i - 1;
+ for (std::size_t i = 0; i < oldList.size() && i < newList.size() && oldList[oldList.size() - i - 1]->m_sha1 == newList[newList.size() - i - 1]->m_sha1; ++i) {
+ std::size_t oldIndex = oldList.size() - i - 1;
+ std::size_t newIndex = newList.size() - i - 1;
oldMap[oldIndex].first = oldList[oldIndex].get();
oldMap[oldIndex].second = newIndex;
newMap[newIndex].first = newList[newIndex].get();
newMap[newIndex].second = oldIndex;
}
- typedef HashMap<String, Vector<size_t> > DiffTable;
+ typedef HashMap<String, Vector<std::size_t> > DiffTable;
DiffTable newTable;
DiffTable oldTable;
- for (size_t i = 0; i < newList.size(); ++i) {
- newTable.add(newList[i]->m_sha1, Vector<size_t>()).storedValue->value.append(i);
+ for (std::size_t i = 0; i < newList.size(); ++i) {
+ newTable.add(newList[i]->m_sha1, Vector<std::size_t>()).storedValue->value.append(i);
}
- for (size_t i = 0; i < oldList.size(); ++i) {
- oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).storedValue->value.append(i);
+ for (std::size_t i = 0; i < oldList.size(); ++i) {
+ oldTable.add(oldList[i]->m_sha1, Vector<std::size_t>()).storedValue->value.append(i);
}
for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end(); ++newIt) {
@@ -265,29 +263,29 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt
if (oldIt == oldTable.end() || oldIt->value.size() != 1)
continue;
- newMap[newIt->value[0]] = make_pair(newList[newIt->value[0]].get(), oldIt->value[0]);
- oldMap[oldIt->value[0]] = make_pair(oldList[oldIt->value[0]].get(), newIt->value[0]);
+ newMap[newIt->value[0]] = std::make_pair(newList[newIt->value[0]].get(), oldIt->value[0]);
+ oldMap[oldIt->value[0]] = std::make_pair(oldList[oldIt->value[0]].get(), newIt->value[0]);
}
- for (size_t i = 0; newList.size() > 0 && i < newList.size() - 1; ++i) {
+ for (std::size_t i = 0; newList.size() > 0 && i < newList.size() - 1; ++i) {
if (!newMap[i].first || newMap[i + 1].first)
continue;
- size_t j = newMap[i].second + 1;
+ std::size_t j = newMap[i].second + 1;
if (j < oldMap.size() && !oldMap[j].first && newList[i + 1]->m_sha1 == oldList[j]->m_sha1) {
- newMap[i + 1] = make_pair(newList[i + 1].get(), j);
- oldMap[j] = make_pair(oldList[j].get(), i + 1);
+ newMap[i + 1] = std::make_pair(newList[i + 1].get(), j);
+ oldMap[j] = std::make_pair(oldList[j].get(), i + 1);
}
}
- for (size_t i = newList.size() - 1; newList.size() > 0 && i > 0; --i) {
+ for (std::size_t i = newList.size() - 1; newList.size() > 0 && i > 0; --i) {
if (!newMap[i].first || newMap[i - 1].first || newMap[i].second <= 0)
continue;
- size_t j = newMap[i].second - 1;
+ std::size_t j = newMap[i].second - 1;
if (!oldMap[j].first && newList[i - 1]->m_sha1 == oldList[j]->m_sha1) {
- newMap[i - 1] = make_pair(newList[i - 1].get(), j);
- oldMap[j] = make_pair(oldList[j].get(), i - 1);
+ newMap[i - 1] = std::make_pair(newList[i - 1].get(), j);
+ oldMap[j] = std::make_pair(oldList[j].get(), i - 1);
}
}
@@ -296,7 +294,7 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt
dumpMap(newMap, "NEW");
#endif
- return make_pair(oldMap, newMap);
+ return std::make_pair(oldMap, newMap);
}
bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPtr<Digest> >& newList, ExceptionState& exceptionState)
@@ -310,8 +308,8 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
// 1. First strip everything except for the nodes that retain. Collect pending merges.
HashMap<Digest*, Digest*> merges;
- HashSet<size_t, WTF::IntHash<size_t>, WTF::UnsignedWithZeroKeyHashTraits<size_t> > usedNewOrdinals;
- for (size_t i = 0; i < oldList.size(); ++i) {
+ HashSet<std::size_t, WTF::IntHash<std::size_t>, WTF::UnsignedWithZeroKeyHashTraits<std::size_t> > usedNewOrdinals;
+ for (std::size_t i = 0; i < oldList.size(); ++i) {
if (oldMap[i].first) {
if (usedNewOrdinals.add(oldMap[i].second).isNewEntry)
continue;
@@ -332,8 +330,8 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
// Check if this change is between stable nodes. If it is, consider it as "modified".
if (!m_unusedNodesMap.contains(oldList[i]->m_sha1) && (!i || oldMap[i - 1].first) && (i == oldMap.size() - 1 || oldMap[i + 1].first)) {
- size_t anchorCandidate = i ? oldMap[i - 1].second + 1 : 0;
- size_t anchorAfter = (i == oldMap.size() - 1) ? anchorCandidate + 1 : oldMap[i + 1].second;
+ std::size_t anchorCandidate = i ? oldMap[i - 1].second + 1 : 0;
+ std::size_t anchorAfter = (i == oldMap.size() - 1) ? anchorCandidate + 1 : oldMap[i + 1].second;
if (anchorAfter - anchorCandidate == 1 && anchorCandidate < newList.size())
merges.set(newList[anchorCandidate].get(), oldList[i].get());
else {
@@ -347,11 +345,11 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
}
// Mark retained nodes as used, do not reuse node more than once.
- HashSet<size_t, WTF::IntHash<size_t>, WTF::UnsignedWithZeroKeyHashTraits<size_t> > usedOldOrdinals;
- for (size_t i = 0; i < newList.size(); ++i) {
+ HashSet<std::size_t, WTF::IntHash<std::size_t>, WTF::UnsignedWithZeroKeyHashTraits<std::size_t> > usedOldOrdinals;
+ for (std::size_t i = 0; i < newList.size(); ++i) {
if (!newMap[i].first)
continue;
- size_t oldOrdinal = newMap[i].second;
+ std::size_t oldOrdinal = newMap[i].second;
if (usedOldOrdinals.contains(oldOrdinal)) {
// Do not map node more than once
newMap[i].first = 0;
@@ -364,7 +362,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
// Mark <head> and <body> nodes for merge.
if (oldHead || oldBody) {
- for (size_t i = 0; i < newList.size(); ++i) {
+ for (std::size_t i = 0; i < newList.size(); ++i) {
if (oldHead && isHTMLHeadElement(*newList[i]->m_node))
merges.set(newList[i].get(), oldHead);
if (oldBody && isHTMLBodyElement(*newList[i]->m_node))
@@ -379,7 +377,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
}
// 3. Insert missing nodes.
- for (size_t i = 0; i < newMap.size(); ++i) {
+ for (std::size_t i = 0; i < newMap.size(); ++i) {
if (newMap[i].first || merges.contains(newList[i].get()))
continue;
if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode->traverseToChildAt(i), exceptionState))
@@ -387,7 +385,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
}
// 4. Then put all nodes that retained into their slots (sort by new index).
- for (size_t i = 0; i < oldMap.size(); ++i) {
+ for (std::size_t i = 0; i < oldMap.size(); ++i) {
if (!oldMap[i].first)
continue;
RefPtrWillBeRawPtr<Node> node = oldMap[i].first->m_node;
@@ -481,7 +479,7 @@ bool DOMPatchSupport::removeChildAndMoveToNew(Digest* oldDigest, ExceptionState&
return true;
}
- for (size_t i = 0; i < oldDigest->m_children.size(); ++i) {
+ for (std::size_t i = 0; i < oldDigest->m_children.size(); ++i) {
if (!removeChildAndMoveToNew(oldDigest->m_children[i].get(), exceptionState))
return false;
}
@@ -495,7 +493,7 @@ void DOMPatchSupport::markNodeAsUsed(Digest* digest)
while (!queue.isEmpty()) {
Digest* first = queue.takeFirst();
m_unusedNodesMap.remove(first->m_sha1);
- for (size_t i = 0; i < first->m_children.size(); ++i)
+ for (std::size_t i = 0; i < first->m_children.size(); ++i)
queue.append(first->m_children[i].get());
}
}
@@ -511,7 +509,7 @@ static String nodeName(Node* node)
void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name)
{
fprintf(stderr, "\n\n");
- for (size_t i = 0; i < map.size(); ++i)
+ for (std::size_t i = 0; i < map.size(); ++i)
fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map[i].second);
}
#endif

Powered by Google App Engine
This is Rietveld 408576698