Chromium Code Reviews| Index: Source/core/dom/NodeWithIndex.h |
| diff --git a/Source/core/dom/NodeWithIndex.h b/Source/core/dom/NodeWithIndex.h |
| index 02b6d33c15acdadcd3abdffe27003c6f37e2500e..a67c7bb714fa8e393084136269c385e3a916e56f 100644 |
| --- a/Source/core/dom/NodeWithIndex.h |
| +++ b/Source/core/dom/NodeWithIndex.h |
| @@ -36,7 +36,7 @@ class NodeWithIndex { |
| public: |
| explicit NodeWithIndex(Node& node) |
| : m_node(node) |
| - , m_haveIndex(false) |
| + , m_index(-1) |
|
eseidel
2014/06/02 05:14:10
Why was m_index not initialized before? I guess i
Inactive
2014/06/02 12:10:22
Yes, it wasn't because it did not need to be (acce
|
| { |
| } |
| @@ -44,17 +44,16 @@ public: |
| int index() const |
| { |
| - if (!m_haveIndex) { |
| + if (!hasIndex()) |
| m_index = m_node.nodeIndex(); |
|
eseidel
2014/06/02 05:14:42
Can this ever return negative?
Jeffrey Yasskin
2014/06/02 06:06:16
It would be good to ASSERT that hasIndex() after t
Inactive
2014/06/02 12:10:22
No it cannot, this is why my change is safe. As ex
Inactive
2014/06/02 12:10:22
Makes sense, will do.
Inactive
2014/06/02 12:12:20
Done.
|
| - m_haveIndex = true; |
| - } |
| ASSERT(m_index == static_cast<int>(m_node.nodeIndex())); |
| return m_index; |
| } |
| private: |
| + bool hasIndex() const { return m_index >= 0; } |
| + |
| Node& m_node; |
| - mutable bool m_haveIndex; |
| mutable int m_index; |
| }; |