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

Unified Diff: third_party/WebKit/Source/platform/wtf/TerminatedArrayBuilder.h

Issue 2774333002: Revert "Move files in wtf/ to platform/wtf/" (Closed)
Patch Set: 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/platform/wtf/TerminatedArrayBuilder.h
diff --git a/third_party/WebKit/Source/platform/wtf/TerminatedArrayBuilder.h b/third_party/WebKit/Source/platform/wtf/TerminatedArrayBuilder.h
deleted file mode 100644
index f49cbea095a8a7fe28d071fbef54a224bdeed8dc..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/platform/wtf/TerminatedArrayBuilder.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2014 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 "platform/wtf/Allocator.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
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/TerminatedArray.h ('k') | third_party/WebKit/Source/platform/wtf/ThreadSpecificWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698