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

Unified Diff: third_party/WebKit/Source/core/xml/XPathStep.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
« no previous file with comments | « third_party/WebKit/Source/core/xml/XPathPredicate.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/xml/XPathStep.cpp
diff --git a/third_party/WebKit/Source/core/xml/XPathStep.cpp b/third_party/WebKit/Source/core/xml/XPathStep.cpp
index 1ec97601ad75e437989dcb98ee50e628411f89ea..3872240c594c11e4a73f6b0a945a62f1c4811f6e 100644
--- a/third_party/WebKit/Source/core/xml/XPathStep.cpp
+++ b/third_party/WebKit/Source/core/xml/XPathStep.cpp
@@ -65,8 +65,7 @@ void Step::optimize() {
// list sensitive, or to first predicate that is only context position
// sensitive, e.g. foo[position() mod 2 = 0].
HeapVector<Member<Predicate>> remainingPredicates;
- for (size_t i = 0; i < m_predicates.size(); ++i) {
- Predicate* predicate = m_predicates[i];
+ for (const auto& predicate : m_predicates) {
if ((!predicate->isContextPositionSensitive() ||
nodeTest().mergedPredicates().isEmpty()) &&
!predicate->isContextSizeSensitive() && remainingPredicates.isEmpty()) {
@@ -105,15 +104,13 @@ bool optimizeStepPair(Step* first, Step* second) {
}
bool Step::predicatesAreContextListInsensitive() const {
- for (size_t i = 0; i < m_predicates.size(); ++i) {
- Predicate* predicate = m_predicates[i].get();
+ for (const auto& predicate : m_predicates) {
if (predicate->isContextPositionSensitive() ||
predicate->isContextSizeSensitive())
return false;
}
- for (size_t i = 0; i < nodeTest().mergedPredicates().size(); ++i) {
- Predicate* predicate = nodeTest().mergedPredicates()[i].get();
+ for (const auto& predicate : nodeTest().mergedPredicates()) {
if (predicate->isContextPositionSensitive() ||
predicate->isContextSizeSensitive())
return false;
@@ -130,9 +127,7 @@ void Step::evaluate(EvaluationContext& evaluationContext,
nodesInAxis(evaluationContext, context, nodes);
// Check predicates that couldn't be merged into node test.
- for (unsigned i = 0; i < m_predicates.size(); i++) {
- Predicate* predicate = m_predicates[i].get();
-
+ for (const auto& predicate : m_predicates) {
NodeSet* newNodes = NodeSet::create();
if (!nodes.isSorted())
newNodes->markSorted(false);
@@ -246,11 +241,7 @@ static inline bool nodeMatches(EvaluationContext& evaluationContext,
// Only the first merged predicate may depend on position.
++evaluationContext.position;
- const HeapVector<Member<Predicate>>& mergedPredicates =
- nodeTest.mergedPredicates();
- for (unsigned i = 0; i < mergedPredicates.size(); i++) {
- Predicate* predicate = mergedPredicates[i].get();
-
+ for (const auto& predicate : nodeTest.mergedPredicates()) {
evaluationContext.node = node;
// No need to set context size - we only get here when evaluating
// predicates that do not depend on it.
« no previous file with comments | « third_party/WebKit/Source/core/xml/XPathPredicate.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698