Chromium Code Reviews| Index: third_party/WebKit/Source/platform/inspector_protocol/CollectionsSTL.h |
| diff --git a/third_party/WebKit/Source/platform/inspector_protocol/CollectionsSTL.h b/third_party/WebKit/Source/platform/inspector_protocol/CollectionsSTL.h |
| index d141f30e7023896d9bb6590f2758e7e9f5ac69c9..43ad799fd973343720940537605b337065e873f9 100644 |
| --- a/third_party/WebKit/Source/platform/inspector_protocol/CollectionsSTL.h |
| +++ b/third_party/WebKit/Source/platform/inspector_protocol/CollectionsSTL.h |
| @@ -5,8 +5,8 @@ |
| #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> |
| @@ -15,8 +15,14 @@ |
| namespace std { |
| template<> |
| -struct hash<String> { |
| - std::size_t operator()(const String& k) const { return StringHash::hash(k); } |
| +struct hash<String16> { |
| +std::size_t operator()(const String16& k) const |
| +{ |
| + size_t hash = 0; |
|
kozy
2016/04/12 17:09:59
StringHash::hash caches result. Can we add cache h
|
| + for (size_t i = 0; i < k.length(); ++i) |
| + hash += 31 * k[i]; |
|
alph
2016/04/12 19:05:25
looks like a very bad hash. This is basically just
kozy
2016/04/12 19:07:50
Or we can reuse calculateHash from V8DebuggerAgent
|
| + return hash; |
| +} |
| }; |
| } |
| @@ -62,6 +68,7 @@ class Vector<OwnPtr<T>> { |
| 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 +93,7 @@ public: |
| 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: |