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

Unified Diff: third_party/WebKit/Source/wtf/TerminatedArray.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/TerminatedArray.h
diff --git a/third_party/WebKit/Source/wtf/TerminatedArray.h b/third_party/WebKit/Source/wtf/TerminatedArray.h
index 6daba4bdb4b26142fd63293e46fc16d70e57a297..0440a42d2026f383c0acf8658ca691c1bcb3c2e6 100644
--- a/third_party/WebKit/Source/wtf/TerminatedArray.h
+++ b/third_party/WebKit/Source/wtf/TerminatedArray.h
@@ -14,89 +14,99 @@ namespace WTF {
// element knows whether it is the last element in the sequence or not. For this
// check type T must provide isLastInArray method.
// TerminatedArray<T> can only be constructed by TerminatedArrayBuilder<T>.
-template<typename T>
+template <typename T>
class TerminatedArray {
- DISALLOW_NEW();
- WTF_MAKE_NONCOPYABLE(TerminatedArray);
-public:
- T& at(size_t index) { return reinterpret_cast<T*>(this)[index]; }
- const T& at(size_t index) const { return reinterpret_cast<const T*>(this)[index]; }
-
- template<typename U>
- class iterator_base final {
- STACK_ALLOCATED();
- public:
- iterator_base& operator++()
- {
- if (m_val->isLastInArray()) {
- m_val = 0;
- } else {
- ++m_val;
- }
- return *this;
- }
-
- U& operator*() const { return *m_val; }
-
- bool operator==(const iterator_base& other) const { return m_val == other.m_val; }
- bool operator!=(const iterator_base& other) const { return !(*this == other); }
-
- private:
- iterator_base(U* val) : m_val(val) { }
-
- U* m_val;
-
- friend class TerminatedArray;
- };
-
- typedef iterator_base<T> iterator;
- typedef iterator_base<const T> const_iterator;
-
- iterator begin() { return iterator(reinterpret_cast<T*>(this)); }
- const_iterator begin() const { return const_iterator(reinterpret_cast<const T*>(this)); }
-
- iterator end() { return iterator(0); }
- const_iterator end() const { return const_iterator(0); }
-
- size_t size() const
- {
- size_t count = 0;
- for (const_iterator it = begin(); it != end(); ++it)
- count++;
- return count;
+ DISALLOW_NEW();
+ WTF_MAKE_NONCOPYABLE(TerminatedArray);
+
+ public:
+ T& at(size_t index) { return reinterpret_cast<T*>(this)[index]; }
+ const T& at(size_t index) const {
+ return reinterpret_cast<const T*>(this)[index];
+ }
+
+ template <typename U>
+ class iterator_base final {
+ STACK_ALLOCATED();
+
+ public:
+ iterator_base& operator++() {
+ if (m_val->isLastInArray()) {
+ m_val = 0;
+ } else {
+ ++m_val;
+ }
+ return *this;
}
- // Match Allocator semantics to be able to use OwnPtr<TerminatedArray>.
- void operator delete(void* p) { ::WTF::Partitions::fastFree(p); }
-
-private:
- // Allocator describes how TerminatedArrayBuilder should create new instances
- // of TerminateArray and manage their lifetimes.
- struct Allocator {
- STATIC_ONLY(Allocator);
- typedef PassOwnPtr<TerminatedArray> PassPtr;
- typedef OwnPtr<TerminatedArray> Ptr;
-
- static PassPtr create(size_t capacity)
- {
- return adoptPtr(static_cast<TerminatedArray*>(WTF::Partitions::fastMalloc(capacity * sizeof(T), WTF_HEAP_PROFILER_TYPE_NAME(T))));
- }
-
- static PassPtr resize(PassPtr ptr, size_t capacity)
- {
- return adoptPtr(static_cast<TerminatedArray*>(WTF::Partitions::fastRealloc(ptr.leakPtr(), capacity * sizeof(T), WTF_HEAP_PROFILER_TYPE_NAME(T))));
- }
- };
-
- // Prohibit construction. Allocator makes TerminatedArray instances for
- // TerminatedArrayBuilder by pointer casting.
- TerminatedArray();
-
- template<typename, template <typename> class> friend class TerminatedArrayBuilder;
+ U& operator*() const { return *m_val; }
+
+ bool operator==(const iterator_base& other) const {
+ return m_val == other.m_val;
+ }
+ bool operator!=(const iterator_base& other) const {
+ return !(*this == other);
+ }
+
+ private:
+ iterator_base(U* val) : m_val(val) {}
+
+ U* m_val;
+
+ friend class TerminatedArray;
+ };
+
+ typedef iterator_base<T> iterator;
+ typedef iterator_base<const T> const_iterator;
+
+ iterator begin() { return iterator(reinterpret_cast<T*>(this)); }
+ const_iterator begin() const {
+ return const_iterator(reinterpret_cast<const T*>(this));
+ }
+
+ iterator end() { return iterator(0); }
+ const_iterator end() const { return const_iterator(0); }
+
+ size_t size() const {
+ size_t count = 0;
+ for (const_iterator it = begin(); it != end(); ++it)
+ count++;
+ return count;
+ }
+
+ // Match Allocator semantics to be able to use OwnPtr<TerminatedArray>.
+ void operator delete(void* p) { ::WTF::Partitions::fastFree(p); }
+
+ private:
+ // Allocator describes how TerminatedArrayBuilder should create new instances
+ // of TerminateArray and manage their lifetimes.
+ struct Allocator {
+ STATIC_ONLY(Allocator);
+ typedef PassOwnPtr<TerminatedArray> PassPtr;
+ typedef OwnPtr<TerminatedArray> Ptr;
+
+ static PassPtr create(size_t capacity) {
+ return adoptPtr(static_cast<TerminatedArray*>(WTF::Partitions::fastMalloc(
+ capacity * sizeof(T), WTF_HEAP_PROFILER_TYPE_NAME(T))));
+ }
+
+ static PassPtr resize(PassPtr ptr, size_t capacity) {
+ return adoptPtr(static_cast<TerminatedArray*>(
+ WTF::Partitions::fastRealloc(ptr.leakPtr(), capacity * sizeof(T),
+ WTF_HEAP_PROFILER_TYPE_NAME(T))));
+ }
+ };
+
+ // Prohibit construction. Allocator makes TerminatedArray instances for
+ // TerminatedArrayBuilder by pointer casting.
+ TerminatedArray();
+
+ template <typename, template <typename> class>
+ friend class TerminatedArrayBuilder;
};
-} // namespace WTF
+} // namespace WTF
using WTF::TerminatedArray;
-#endif // TerminatedArray_h
+#endif // TerminatedArray_h
« no previous file with comments | « third_party/WebKit/Source/wtf/TemporaryChangeTest.cpp ('k') | third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698