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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBKey.h

Issue 2635403002: IndexedDB: Replace O(n^2) algorithm computing multientry index keys (Closed)
Patch Set: std::copy_if for the STL trifecta Created 3 years, 11 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/modules/indexeddb/IDBKey.h
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBKey.h b/third_party/WebKit/Source/modules/indexeddb/IDBKey.h
index cbbf32c3dac8ffbf69dcfd5961744206b8f61e62..04be992612058233aab08123232b089514f459c2 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBKey.h
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBKey.h
@@ -32,6 +32,7 @@
#include "wtf/Forward.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
+#include <utility>
namespace blink {
@@ -55,28 +56,7 @@ class MODULES_EXPORT IDBKey : public GarbageCollectedFinalized<IDBKey> {
static IDBKey* createDate(double date) { return new IDBKey(DateType, date); }
- static IDBKey* createMultiEntryArray(const KeyArray& array) {
- KeyArray result;
-
- for (size_t i = 0; i < array.size(); i++) {
- if (!array[i]->isValid())
- continue;
-
- bool skip = false;
- for (size_t j = 0; j < result.size(); j++) {
- if (array[i]->isEqual(result[j].get())) {
- skip = true;
- break;
- }
- }
- if (!skip) {
- result.push_back(array[i]);
- }
- }
- IDBKey* idbKey = new IDBKey(result);
- ASSERT(idbKey->isValid());
- return idbKey;
- }
+ static IDBKey* createMultiEntryArray(const KeyArray&);
static IDBKey* createArray(const KeyArray& array) {
return new IDBKey(array);
@@ -136,6 +116,8 @@ class MODULES_EXPORT IDBKey : public GarbageCollectedFinalized<IDBKey> {
: m_type(BinaryType), m_binary(value) {}
explicit IDBKey(const KeyArray& keyArray)
: m_type(ArrayType), m_array(keyArray) {}
+ explicit IDBKey(KeyArray&& keyArray)
+ : m_type(ArrayType), m_array(std::move(keyArray)) {}
const Type m_type;
const KeyArray m_array;

Powered by Google App Engine
This is Rietveld 408576698