OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 2 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 parentsVector.append(n); | 155 parentsVector.append(n); |
156 containsAttributeNodes = true; | 156 containsAttributeNodes = true; |
157 } | 157 } |
158 while ((n = n->parent())) | 158 while ((n = n->parent())) |
159 parentsVector.append(n); | 159 parentsVector.append(n); |
160 } | 160 } |
161 sortBlock(0, nodeCount, parentMatrix, containsAttributeNodes); | 161 sortBlock(0, nodeCount, parentMatrix, containsAttributeNodes); |
162 | 162 |
163 // It is not possible to just assign the result to m_nodes, because some nod
es may get dereferenced and destroyed. | 163 // It is not possible to just assign the result to m_nodes, because some nod
es may get dereferenced and destroyed. |
164 Vector<RefPtr<Node> > sortedNodes; | 164 Vector<RefPtr<Node> > sortedNodes; |
165 sortedNodes.reserveCapacity(nodeCount); | 165 sortedNodes.reserveInitialCapacity(nodeCount); |
166 for (unsigned i = 0; i < nodeCount; ++i) | 166 for (unsigned i = 0; i < nodeCount; ++i) |
167 sortedNodes.append(parentMatrix[i][0]); | 167 sortedNodes.append(parentMatrix[i][0]); |
168 | 168 |
169 const_cast<Vector<RefPtr<Node> >& >(m_nodes).swap(sortedNodes); | 169 const_cast<Vector<RefPtr<Node> >& >(m_nodes).swap(sortedNodes); |
170 } | 170 } |
171 | 171 |
172 void NodeSet::reverse() | 172 void NodeSet::reverse() |
173 { | 173 { |
174 if (m_nodes.isEmpty()) | 174 if (m_nodes.isEmpty()) |
175 return; | 175 return; |
(...skipping 21 matching lines...) Expand all Loading... |
197 if (isEmpty()) | 197 if (isEmpty()) |
198 return 0; | 198 return 0; |
199 | 199 |
200 return m_nodes.at(0).get(); | 200 return m_nodes.at(0).get(); |
201 } | 201 } |
202 | 202 |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 #endif // ENABLE(XPATH) | 206 #endif // ENABLE(XPATH) |
OLD | NEW |