Move to protocol::Vector This change is required to reduce the reliance on the WTF::Vector in the DevTools. 1. Debugger now uses protocol::Vector instead of WTF::Vector 2. Move ctor and swap(...) methods were added to a Vector specialization that keeps OwnPtr. BUG= Review URL: https://codereview.chromium.org/1880833002 Cr-Original-Commit-Position: refs/heads/master@{#386869} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 7b77df61133496c06995988ee2f5a1d8ad8384e9
diff --git a/CollectionsSTL.h b/CollectionsSTL.h index d141f30..0ac816b 100644 --- a/CollectionsSTL.h +++ b/CollectionsSTL.h
@@ -5,20 +5,14 @@ #ifndef CollectionsSTL_h #define CollectionsSTL_h -#include "wtf/Allocator.h" -#include "wtf/HashMap.h" +#include "platform/inspector_protocol/String16.h" +#include "wtf/OwnPtr.h" #include "wtf/PassOwnPtr.h" #include <algorithm> #include <unordered_map> #include <vector> -namespace std { -template<> -struct hash<String> { - std::size_t operator()(const String& k) const { return StringHash::hash(k); } -}; -} namespace blink { namespace protocol { @@ -62,6 +56,7 @@ public: Vector() { } Vector(size_t capacity) : m_impl(capacity) { } + Vector(Vector&& other) : m_impl(std::move(other.m_impl)) { } ~Vector() { } typedef typename std::vector<OwnPtr<T>>::iterator iterator; @@ -86,6 +81,7 @@ void remove(size_t i) { m_impl.erase(m_impl.begin() + i); } void clear() { m_impl.clear(); } void swap(Vector& other) { m_impl.swap(other.m_impl); } + void swap(Vector&& other) { m_impl.swap(other.m_impl); } void removeLast() { m_impl.pop_back(); } private:
diff --git a/CollectionsWTF.h b/CollectionsWTF.h index 47986cc..f2728e7 100644 --- a/CollectionsWTF.h +++ b/CollectionsWTF.h
@@ -40,7 +40,7 @@ void prepend(const T& t) { m_impl.prepend(t); } void remove(size_t i) { m_impl.remove(i); } void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } + void swap(Vector<T>& other) { m_impl.swap(other.m_impl); } void removeLast() { m_impl.removeLast(); } private: @@ -53,6 +53,7 @@ public: Vector() { } Vector(size_t capacity) : m_impl(capacity) { } + Vector(Vector<OwnPtr<T>>&& other) : m_impl(std::move(other.m_impl)) { } ~Vector() { } typedef OwnPtr<T>* iterator; @@ -76,7 +77,8 @@ void prepend(PassOwnPtr<T> t) { m_impl.prepend(t); } void remove(size_t i) { m_impl.remove(i); } void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } + void swap(Vector<OwnPtr<T>>& other) { m_impl.swap(other.m_impl); } + void swap(Vector<OwnPtr<T>>&& other) { m_impl.swap(other.m_impl); } void removeLast() { m_impl.removeLast(); } private: