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

Unified Diff: third_party/WebKit/Source/wtf/Vector.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 | « third_party/WebKit/Source/wtf/ThreadingWin.cpp ('k') | third_party/WebKit/Source/wtf/VectorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Vector.h
diff --git a/third_party/WebKit/Source/wtf/Vector.h b/third_party/WebKit/Source/wtf/Vector.h
index 9722d7eaf906fa9b3ba5615311f2c6ea71f8c43c..5b50284b29f3c98f244e66884144907583cd4659 100644
--- a/third_party/WebKit/Source/wtf/Vector.h
+++ b/third_party/WebKit/Source/wtf/Vector.h
@@ -271,6 +271,26 @@ struct VectorComparer<true, T> {
};
template <typename T>
+struct VectorElementComparer {
+ STATIC_ONLY(VectorElementComparer);
+ template <typename U>
+ static bool compareElement(const T& left, const U& right)
+ {
+ return left == right;
+ }
+};
+
+template <typename T>
+struct VectorElementComparer<std::unique_ptr<T>> {
+ STATIC_ONLY(VectorElementComparer);
+ template <typename U>
+ static bool compareElement(const std::unique_ptr<T>& left, const U& right)
+ {
+ return left.get() == right;
+ }
+};
+
+template <typename T>
struct VectorTypeOperations {
STATIC_ONLY(VectorTypeOperations);
static void destruct(T* begin, T* end)
@@ -312,6 +332,12 @@ struct VectorTypeOperations {
{
return VectorComparer<VectorTraits<T>::canCompareWithMemcmp, T>::compare(a, b, size);
}
+
+ template <typename U>
+ static bool compareElement(const T& left, U&& right)
+ {
+ return VectorElementComparer<T>::compareElement(left, std::forward<U>(right));
+ }
};
template <typename T, bool hasInlineCapacity, typename Allocator>
@@ -1095,7 +1121,7 @@ size_t Vector<T, inlineCapacity, Allocator>::find(const U& value) const
const T* b = begin();
const T* e = end();
for (const T* iter = b; iter < e; ++iter) {
- if (*iter == value)
+ if (TypeOperations::compareElement(*iter, value))
return iter - b;
}
return kNotFound;
@@ -1109,7 +1135,7 @@ size_t Vector<T, inlineCapacity, Allocator>::reverseFind(const U& value) const
const T* iter = end();
while (iter > b) {
--iter;
- if (*iter == value)
+ if (TypeOperations::compareElement(*iter, value))
return iter - b;
}
return kNotFound;
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadingWin.cpp ('k') | third_party/WebKit/Source/wtf/VectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698