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

Unified Diff: third_party/WebKit/Source/core/xml/XPathPath.cpp

Issue 2560823003: Avoid WTF::Vector::at() and operator[] in core/xml. (Closed)
Patch Set: Created 4 years 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: third_party/WebKit/Source/core/xml/XPathPath.cpp
diff --git a/third_party/WebKit/Source/core/xml/XPathPath.cpp b/third_party/WebKit/Source/core/xml/XPathPath.cpp
index cca8b44e549d73ac3300544bdae8549c7501a71d..f5eb17ae3e10a85ce183bc8490be4a0efa1a815e 100644
--- a/third_party/WebKit/Source/core/xml/XPathPath.cpp
+++ b/third_party/WebKit/Source/core/xml/XPathPath.cpp
@@ -58,18 +58,16 @@ Value Filter::evaluate(EvaluationContext& evaluationContext) const {
NodeSet& nodes = v.modifiableNodeSet(evaluationContext);
nodes.sort();
- for (unsigned i = 0; i < m_predicates.size(); i++) {
+ for (const auto& predicate : m_predicates) {
NodeSet* newNodes = NodeSet::create();
evaluationContext.size = nodes.size();
evaluationContext.position = 0;
- for (unsigned j = 0; j < nodes.size(); j++) {
- Node* node = nodes[j];
-
+ for (const auto& node : nodes) {
evaluationContext.node = node;
++evaluationContext.position;
- if (m_predicates[i]->evaluate(evaluationContext))
+ if (predicate->evaluate(evaluationContext))
newNodes->append(node);
}
nodes.swap(*newNodes);
@@ -119,8 +117,7 @@ Value LocationPath::evaluate(EvaluationContext& evaluationContext) const {
void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const {
bool resultIsSorted = nodes.isSorted();
- for (unsigned i = 0; i < m_steps.size(); i++) {
- Step* step = m_steps[i];
+ for (const auto& step : m_steps) {
NodeSet* newNodes = NodeSet::create();
HeapHashSet<Member<Node>> newNodesSet;
@@ -140,15 +137,14 @@ void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const {
step->getAxis() == Step::SelfAxis))
newNodes->markSubtreesDisjoint(true);
- for (unsigned j = 0; j < nodes.size(); j++) {
+ for (const auto& inputNode : nodes) {
NodeSet* matches = NodeSet::create();
- step->evaluate(context, nodes[j], *matches);
+ step->evaluate(context, inputNode, *matches);
if (!matches->isSorted())
resultIsSorted = false;
- for (size_t nodeIndex = 0; nodeIndex < matches->size(); ++nodeIndex) {
- Node* node = (*matches)[nodeIndex];
+ for (const auto& node : *matches) {
if (!needToCheckForDuplicateNodes || newNodesSet.add(node).isNewEntry)
newNodes->append(node);
}
« no previous file with comments | « third_party/WebKit/Source/core/xml/XPathParser.cpp ('k') | third_party/WebKit/Source/core/xml/XPathPredicate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698