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

Unified Diff: third_party/WebKit/Source/wtf/TerminatedArrayBuilder.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
Index: third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h
diff --git a/third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h b/third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h
index 020626132993512de9f6a8ceed36261336bde9b6..531d6501d44881c14913eebc9688baaa0feaa99a 100644
--- a/third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h
+++ b/third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h
@@ -1,78 +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 TerminatedArrayBuilder_h
-#define TerminatedArrayBuilder_h
-#include "wtf/Allocator.h"
+#include "platform/wtf/TerminatedArrayBuilder.h"
-namespace WTF {
-
-template <typename T, template <typename> class ArrayType = TerminatedArray>
-class TerminatedArrayBuilder {
- STACK_ALLOCATED();
- WTF_MAKE_NONCOPYABLE(TerminatedArrayBuilder);
-
- public:
- explicit TerminatedArrayBuilder(
- typename ArrayType<T>::Allocator::PassPtr array)
- : m_array(array), m_count(0), m_capacity(0) {
- if (!m_array)
- return;
- m_capacity = m_count = m_array->size();
- DCHECK(m_array->at(m_count - 1).isLastInArray());
- }
-
- void grow(size_t count) {
- DCHECK(count);
- if (!m_array) {
- DCHECK(!m_count);
- DCHECK(!m_capacity);
- m_capacity = count;
- m_array = ArrayType<T>::Allocator::create(m_capacity);
- } else {
- DCHECK(m_array->at(m_count - 1).isLastInArray());
- m_capacity += count;
- m_array = ArrayType<T>::Allocator::resize(
- ArrayType<T>::Allocator::release(m_array), m_capacity);
- m_array->at(m_count - 1).setLastInArray(false);
- }
- m_array->at(m_capacity - 1).setLastInArray(true);
- }
-
- void append(const T& item) {
- RELEASE_ASSERT(m_count < m_capacity);
- DCHECK(!item.isLastInArray());
- m_array->at(m_count++) = item;
- if (m_count == m_capacity)
- m_array->at(m_capacity - 1).setLastInArray(true);
- }
-
- typename ArrayType<T>::Allocator::PassPtr release() {
- RELEASE_ASSERT(m_count == m_capacity);
- assertValid();
- return ArrayType<T>::Allocator::release(m_array);
- }
-
- private:
-#if DCHECK_IS_ON()
- void assertValid() {
- for (size_t i = 0; i < m_count; ++i) {
- bool isLastInArray = (i + 1 == m_count);
- DCHECK_EQ(m_array->at(i).isLastInArray(), isLastInArray);
- }
- }
-#else
- void assertValid() {}
-#endif
-
- typename ArrayType<T>::Allocator::Ptr m_array;
- size_t m_count;
- size_t m_capacity;
-};
-
-} // namespace WTF
-
-using WTF::TerminatedArrayBuilder;
-
-#endif // TerminatedArrayBuilder_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/TerminatedArray.h ('k') | third_party/WebKit/Source/wtf/ThreadSpecificWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698