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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp

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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 if (!indexMetadata.multiEntry || indexKey->getType() != IDBKey::ArrayType) { 324 if (!indexMetadata.multiEntry || indexKey->getType() != IDBKey::ArrayType) {
325 if (!indexKey->isValid()) 325 if (!indexKey->isValid())
326 return; 326 return;
327 327
328 indexKeys->push_back(indexKey); 328 indexKeys->push_back(indexKey);
329 } else { 329 } else {
330 DCHECK(indexMetadata.multiEntry); 330 DCHECK(indexMetadata.multiEntry);
331 DCHECK_EQ(indexKey->getType(), IDBKey::ArrayType); 331 DCHECK_EQ(indexKey->getType(), IDBKey::ArrayType);
332 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); 332 indexKey = IDBKey::createMultiEntryArray(indexKey->array());
333 333 indexKeys->appendVector(indexKey->array());
pwnall 2017/01/18 02:35:19 Would it make sense to have IDBKey::createMultiEnt
jsbell 2017/01/18 18:18:56 Done; also made it non-static to simplify further.
pwnall 2017/01/18 19:04:15 Cool, nice find!
334 for (size_t i = 0; i < indexKey->array().size(); ++i)
335 indexKeys->push_back(indexKey->array()[i]);
336 } 334 }
337 } 335 }
338 336
339 IDBRequest* IDBObjectStore::add(ScriptState* scriptState, 337 IDBRequest* IDBObjectStore::add(ScriptState* scriptState,
340 const ScriptValue& value, 338 const ScriptValue& value,
341 const ScriptValue& key, 339 const ScriptValue& key,
342 ExceptionState& exceptionState) { 340 ExceptionState& exceptionState) {
343 IDB_TRACE("IDBObjectStore::add"); 341 IDB_TRACE("IDBObjectStore::add");
344 return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value, 342 return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value,
345 key, exceptionState); 343 key, exceptionState);
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1089 }
1092 } 1090 }
1093 return IDBIndexMetadata::InvalidId; 1091 return IDBIndexMetadata::InvalidId;
1094 } 1092 }
1095 1093
1096 WebIDBDatabase* IDBObjectStore::backendDB() const { 1094 WebIDBDatabase* IDBObjectStore::backendDB() const {
1097 return m_transaction->backendDB(); 1095 return m_transaction->backendDB();
1098 } 1096 }
1099 1097
1100 } // namespace blink 1098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698