@@ -111,28 +111,32 @@ bool EqTestOp::compare(const Value& lhs, const Value& rhs) const
111111 // there is a node in the first node-set and a node in the second node-set such that the result of
112112 // performing the comparison on the string-values of the two nodes is true.
113113 const NodeSet& rhsSet = rhs.toNodeSet ();
114- for (unsigned lindex = 0 ; lindex < lhsSet. size (); ++lindex)
115- for (unsigned rindex = 0 ; rindex < rhsSet. size (); ++rindex)
116- if (compare (stringValue (lhsSet[lindex]) , stringValue (rhsSet[rindex] )))
114+ for (auto & lhs : lhsSet) {
115+ for (auto & rhs : rhsSet) {
116+ if (compare (stringValue (lhs. get ()) , stringValue (rhs. get () )))
117117 return true ;
118+ }
119+ }
118120 return false ;
119121 }
120122 if (rhs.isNumber ()) {
121123 // If one object to be compared is a node-set and the other is a number, then the comparison will be true
122124 // if and only if there is a node in the node-set such that the result of performing the comparison on the number
123125 // to be compared and on the result of converting the string-value of that node to a number using the number function is true.
124- for (unsigned lindex = 0 ; lindex < lhsSet. size (); ++lindex)
125- if (compare (Value (stringValue (lhsSet[lindex] )).toNumber (), rhs))
126+ for (auto & lhs : lhsSet) {
127+ if (compare (Value (stringValue (lhs. get () )).toNumber (), rhs))
126128 return true ;
129+ }
127130 return false ;
128131 }
129132 if (rhs.isString ()) {
130133 // If one object to be compared is a node-set and the other is a string, then the comparison will be true
131134 // if and only if there is a node in the node-set such that the result of performing the comparison on
132135 // the string-value of the node and the other string is true.
133- for (unsigned lindex = 0 ; lindex < lhsSet. size (); ++lindex)
134- if (compare (stringValue (lhsSet[lindex] ), rhs))
136+ for (auto & lhs : lhsSet) {
137+ if (compare (stringValue (lhs. get () ), rhs))
135138 return true ;
139+ }
136140 return false ;
137141 }
138142 if (rhs.isBoolean ()) {
@@ -146,15 +150,17 @@ bool EqTestOp::compare(const Value& lhs, const Value& rhs) const
146150 if (rhs.isNodeSet ()) {
147151 const NodeSet& rhsSet = rhs.toNodeSet ();
148152 if (lhs.isNumber ()) {
149- for (unsigned rindex = 0 ; rindex < rhsSet. size (); ++rindex)
150- if (compare (lhs, Value (stringValue (rhsSet[rindex] )).toNumber ()))
153+ for (auto & rhs : rhsSet) {
154+ if (compare (lhs, Value (stringValue (rhs. get () )).toNumber ()))
151155 return true ;
156+ }
152157 return false ;
153158 }
154159 if (lhs.isString ()) {
155- for (unsigned rindex = 0 ; rindex < rhsSet. size (); ++rindex)
156- if (compare (lhs, stringValue (rhsSet[rindex] )))
160+ for (auto & rhs : rhsSet) {
161+ if (compare (lhs, stringValue (rhs. get () )))
157162 return true ;
163+ }
158164 return false ;
159165 }
160166 if (lhs.isBoolean ())
@@ -236,13 +242,12 @@ Value Union::evaluate() const
236242 const NodeSet& rhsNodes = rhs.toNodeSet ();
237243
238244 HashSet<Node*> nodes;
239- for (size_t i = 0 ; i < resultSet. size (); ++i )
240- nodes.add (resultSet[i] );
245+ for (auto & result : resultSet)
246+ nodes.add (result. get () );
241247
242- for (size_t i = 0 ; i < rhsNodes.size (); ++i) {
243- Node* node = rhsNodes[i];
244- if (nodes.add (node).isNewEntry )
245- resultSet.append (node);
248+ for (auto & node : rhsNodes) {
249+ if (nodes.add (node.get ()).isNewEntry )
250+ resultSet.append (node.get ());
246251 }
247252
248253 // It would also be possible to perform a merge sort here to avoid making an unsorted result,
0 commit comments