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

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

Issue 2767153004: Move files in wtf/ to platform/wtf/ (Part 12). (Closed)
Patch Set: Rebase. Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/wtf/StackUtil.cpp ('k') | third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18193a4764a80ed26444d047e430fb8d8476dd74..8f937d8fa4902a391a061d6c85e4374a19ba1d7f 100644
--- a/third_party/WebKit/Source/wtf/TerminatedArray.h
+++ b/third_party/WebKit/Source/wtf/TerminatedArray.h
@@ -1,123 +1,9 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef TerminatedArray_h
-#define TerminatedArray_h
-#include "wtf/Allocator.h"
-#include "wtf/PtrUtil.h"
-#include "wtf/VectorTraits.h"
-#include "wtf/allocator/Partitions.h"
-#include <memory>
+#include "platform/wtf/TerminatedArray.h"
-namespace WTF {
-
-// TerminatedArray<T> represents a sequence of elements of type T in which each
-// 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>
-class TerminatedArray {
- DISALLOW_NEW();
- WTF_MAKE_NONCOPYABLE(TerminatedArray);
-
- public:
- // When TerminatedArray::Allocator implementations grow the backing
- // store, old is copied into the new and larger block.
- static_assert(VectorTraits<T>::canCopyWithMemcpy,
- "Array elements must be memory copyable");
-
- 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;
- }
-
- // Match Allocator semantics to be able to use
- // std::unique_ptr<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);
- using PassPtr = std::unique_ptr<TerminatedArray>;
- using Ptr = std::unique_ptr<TerminatedArray>;
-
- static PassPtr release(Ptr& ptr) { return ptr.release(); }
-
- static PassPtr create(size_t capacity) {
- return WTF::wrapUnique(
- static_cast<TerminatedArray*>(WTF::Partitions::fastMalloc(
- capacity * sizeof(T), WTF_HEAP_PROFILER_TYPE_NAME(T))));
- }
-
- static PassPtr resize(Ptr ptr, size_t capacity) {
- return WTF::wrapUnique(static_cast<TerminatedArray*>(
- WTF::Partitions::fastRealloc(ptr.release(), 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
-
-using WTF::TerminatedArray;
-
-#endif // TerminatedArray_h
+// The contents of this header was moved to platform/wtf as part of
+// WTF migration project. See the following post for details:
+// https://groups.google.com/a/chromium.org/d/msg/blink-dev/tLdAZCTlcAA/bYXVT8gYCAAJ
« no previous file with comments | « third_party/WebKit/Source/wtf/StackUtil.cpp ('k') | third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698