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

Unified Diff: Source/wtf/Vector.h

Issue 228403002: Deque: Add HeapDeque and prevent buggy use of swap and operator= (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Ians nit Created 6 years, 8 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 | « Source/wtf/DequeTest.cpp ('k') | Source/wtf/VectorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Vector.h
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
index ab18fe5fe421fae435d5627c5adcc6542d981021..116baabf94792b8fdf1c325de4b168e81e591c4b 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -309,6 +309,11 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
const T* buffer() const { return m_buffer; }
size_t capacity() const { return m_capacity; }
+ void clearUnusedSlots(T* from, T* to)
+ {
+ VectorUnusedSlotClearer<Allocator::isGarbageCollected && (VectorTraits<T>::needsDestruction || ShouldBeTraced<VectorTraits<T> >::value || VectorTraits<T>::isWeak), T>::clear(from, to);
+ }
+
protected:
VectorBufferBase()
: m_buffer(0)
@@ -331,7 +336,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
class VectorBuffer;
template<typename T, typename Allocator>
- class VectorBuffer<T, 0, Allocator> : private VectorBufferBase<T, Allocator> {
+ class VectorBuffer<T, 0, Allocator> : protected VectorBufferBase<T, Allocator> {
private:
typedef VectorBufferBase<T, Allocator> Base;
public:
@@ -376,8 +381,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
using Base::buffer;
using Base::capacity;
- protected:
- using Base::m_size;
+ using Base::clearUnusedSlots;
bool hasOutOfLineBuffer() const
{
@@ -385,13 +389,16 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
return buffer();
}
+ protected:
+ using Base::m_size;
+
private:
using Base::m_buffer;
using Base::m_capacity;
};
template<typename T, size_t inlineCapacity, typename Allocator>
- class VectorBuffer : private VectorBufferBase<T, Allocator> {
+ class VectorBuffer : protected VectorBufferBase<T, Allocator> {
WTF_MAKE_NONCOPYABLE(VectorBuffer);
private:
typedef VectorBufferBase<T, Allocator> Base;
@@ -479,14 +486,14 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
using Base::buffer;
using Base::capacity;
- protected:
- using Base::m_size;
-
bool hasOutOfLineBuffer() const
{
return buffer() && buffer() != inlineBuffer();
}
+ protected:
+ using Base::m_size;
+
private:
using Base::m_buffer;
using Base::m_capacity;
@@ -507,7 +514,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
// vector has a trivial destructor and we use that in a compiler plugin to ensure the
// correctness of non-finalized garbage-collected classes and the use of VectorTraits::needsDestruction.
- // All non-GC managed vectors needs a destructor. This destructor will simply call finalize on the actual vector type.
+ // All non-GC managed vectors need a destructor. This destructor will simply call finalize on the actual vector type.
template<typename Derived, typename Elements, bool hasInlineCapacity, bool isGarbageCollected>
class VectorDestructorBase {
public:
@@ -611,11 +618,6 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
finalize();
}
- void clearUnusedSlots(T* from, T* to)
- {
- VectorUnusedSlotClearer<Allocator::isGarbageCollected && (VectorTraits<T>::needsDestruction || ShouldBeTraced<VectorTraits<T> >::value || VectorTraits<T>::isWeak), T>::clear(from, to);
- }
-
Vector(const Vector&);
template<size_t otherCapacity>
explicit Vector(const Vector<T, otherCapacity, Allocator>&);
@@ -735,6 +737,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
using Base::swapVectorBuffer;
using Base::allocateBuffer;
using Base::allocationSize;
+ using Base::clearUnusedSlots;
};
template<typename T, size_t inlineCapacity, typename Allocator>
« no previous file with comments | « Source/wtf/DequeTest.cpp ('k') | Source/wtf/VectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698