Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/html/CollectionItemsCache.h

Issue 2583233002: Migrate WTF::Vector::append() to ::push_back() [part 7 of N] (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/FormData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 template <class Collection, class NodeType> 80 template <class Collection, class NodeType>
81 unsigned CollectionItemsCache<Collection, NodeType>::nodeCount( 81 unsigned CollectionItemsCache<Collection, NodeType>::nodeCount(
82 const Collection& collection) { 82 const Collection& collection) {
83 if (this->isCachedNodeCountValid()) 83 if (this->isCachedNodeCountValid())
84 return this->cachedNodeCount(); 84 return this->cachedNodeCount();
85 85
86 NodeType* currentNode = collection.traverseToFirst(); 86 NodeType* currentNode = collection.traverseToFirst();
87 unsigned currentIndex = 0; 87 unsigned currentIndex = 0;
88 while (currentNode) { 88 while (currentNode) {
89 m_cachedList.append(currentNode); 89 m_cachedList.push_back(currentNode);
90 currentNode = collection.traverseForwardToOffset( 90 currentNode = collection.traverseForwardToOffset(
91 currentIndex + 1, *currentNode, currentIndex); 91 currentIndex + 1, *currentNode, currentIndex);
92 } 92 }
93 93
94 this->setCachedNodeCount(m_cachedList.size()); 94 this->setCachedNodeCount(m_cachedList.size());
95 m_listValid = true; 95 m_listValid = true;
96 return this->cachedNodeCount(); 96 return this->cachedNodeCount();
97 } 97 }
98 98
99 template <typename Collection, typename NodeType> 99 template <typename Collection, typename NodeType>
100 inline NodeType* CollectionItemsCache<Collection, NodeType>::nodeAt( 100 inline NodeType* CollectionItemsCache<Collection, NodeType>::nodeAt(
101 const Collection& collection, 101 const Collection& collection,
102 unsigned index) { 102 unsigned index) {
103 if (m_listValid) { 103 if (m_listValid) {
104 DCHECK(this->isCachedNodeCountValid()); 104 DCHECK(this->isCachedNodeCountValid());
105 return index < this->cachedNodeCount() ? m_cachedList[index] : nullptr; 105 return index < this->cachedNodeCount() ? m_cachedList[index] : nullptr;
106 } 106 }
107 return Base::nodeAt(collection, index); 107 return Base::nodeAt(collection, index);
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
111 111
112 #endif // CollectionItemsCache_h 112 #endif // CollectionItemsCache_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/FormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698