| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012,2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2012,2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2014 Apple Inc. 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void invalidate(); | 59 void invalidate(); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 ptrdiff_t allocationSize() const { return m_cachedList.capacity() * sizeof(N
odeType*); } | 62 ptrdiff_t allocationSize() const { return m_cachedList.capacity() * sizeof(N
odeType*); } |
| 63 static void reportExtraMemoryCostForCollectionItemsCache(ptrdiff_t diff) | 63 static void reportExtraMemoryCostForCollectionItemsCache(ptrdiff_t diff) |
| 64 { | 64 { |
| 65 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); | 65 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool m_listValid; | 68 bool m_listValid; |
| 69 WillBeHeapVector<RawPtrWillBeMember<NodeType>> m_cachedList; | 69 HeapVector<Member<NodeType>> m_cachedList; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 template <typename Collection, typename NodeType> | 72 template <typename Collection, typename NodeType> |
| 73 CollectionItemsCache<Collection, NodeType>::CollectionItemsCache() | 73 CollectionItemsCache<Collection, NodeType>::CollectionItemsCache() |
| 74 : m_listValid(false) | 74 : m_listValid(false) |
| 75 { | 75 { |
| 76 } | 76 } |
| 77 | 77 |
| 78 template <typename Collection, typename NodeType> | 78 template <typename Collection, typename NodeType> |
| 79 CollectionItemsCache<Collection, NodeType>::~CollectionItemsCache() | 79 CollectionItemsCache<Collection, NodeType>::~CollectionItemsCache() |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (m_listValid) { | 119 if (m_listValid) { |
| 120 ASSERT(this->isCachedNodeCountValid()); | 120 ASSERT(this->isCachedNodeCountValid()); |
| 121 return index < this->cachedNodeCount() ? m_cachedList[index] : nullptr; | 121 return index < this->cachedNodeCount() ? m_cachedList[index] : nullptr; |
| 122 } | 122 } |
| 123 return Base::nodeAt(collection, index); | 123 return Base::nodeAt(collection, index); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| 127 | 127 |
| 128 #endif // CollectionItemsCache_h | 128 #endif // CollectionItemsCache_h |
| OLD | NEW |