OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 ALWAYS_INLINE bool isCachedNodeCountValid() const { return m_isLengthCacheVa
lid; } | 85 ALWAYS_INLINE bool isCachedNodeCountValid() const { return m_isLengthCacheVa
lid; } |
86 ALWAYS_INLINE unsigned cachedNodeCount() const { return m_cachedNodeCount; } | 86 ALWAYS_INLINE unsigned cachedNodeCount() const { return m_cachedNodeCount; } |
87 ALWAYS_INLINE void setCachedNodeCount(unsigned length) | 87 ALWAYS_INLINE void setCachedNodeCount(unsigned length) |
88 { | 88 { |
89 m_cachedNodeCount = length; | 89 m_cachedNodeCount = length; |
90 m_isLengthCacheValid = true; | 90 m_isLengthCacheValid = true; |
91 } | 91 } |
92 | 92 |
93 RawPtrWillBeMember<NodeType> m_currentNode; | 93 RawPtrWillBeMember<NodeType> m_currentNode; |
94 unsigned m_cachedNodeCount; | 94 unsigned m_cachedNodeCount; |
95 unsigned m_cachedNodeIndex; | 95 unsigned m_cachedNodeIndex : 31; |
96 unsigned m_isLengthCacheValid : 1; | 96 unsigned m_isLengthCacheValid : 1; |
97 }; | 97 }; |
98 | 98 |
99 template <typename Collection, typename NodeType> | 99 template <typename Collection, typename NodeType> |
100 CollectionIndexCache<Collection, NodeType>::CollectionIndexCache() | 100 CollectionIndexCache<Collection, NodeType>::CollectionIndexCache() |
101 : m_currentNode(nullptr) | 101 : m_currentNode(nullptr) |
102 , m_cachedNodeCount(0) | 102 , m_cachedNodeCount(0) |
103 , m_cachedNodeIndex(0) | 103 , m_cachedNodeIndex(0) |
104 , m_isLengthCacheValid(false) | 104 , m_isLengthCacheValid(false) |
105 { | 105 { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 setCachedNodeCount(currentIndex + 1); | 199 setCachedNodeCount(currentIndex + 1); |
200 return 0; | 200 return 0; |
201 } | 201 } |
202 setCachedNode(currentNode, currentIndex); | 202 setCachedNode(currentNode, currentIndex); |
203 return currentNode; | 203 return currentNode; |
204 } | 204 } |
205 | 205 |
206 } // namespace WebCore | 206 } // namespace WebCore |
207 | 207 |
208 #endif // CollectionIndexCache_h | 208 #endif // CollectionIndexCache_h |
OLD | NEW |