Title: [249729] trunk/Source/WebCore
- Revision
- 249729
- Author
- sihui_...@apple.com
- Date
- 2019-09-10 12:42:30 -0700 (Tue, 10 Sep 2019)
Log Message
IndexedDB: cache prepared SQLiteStatement in SQLiteIDBCursor
https://bugs.webkit.org/show_bug.cgi?id=201548
Reviewed by Alex Christensen.
This should be a performance improvement as we don't compile the same SQLiteStatement everytime it is used.
No new tests, no behavior change.
* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
* Modules/indexeddb/server/SQLiteIDBCursor.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (249728 => 249729)
--- trunk/Source/WebCore/ChangeLog 2019-09-10 19:07:21 UTC (rev 249728)
+++ trunk/Source/WebCore/ChangeLog 2019-09-10 19:42:30 UTC (rev 249729)
@@ -1,3 +1,18 @@
+2019-09-10 Sihui Liu <sihui_...@apple.com>
+
+ IndexedDB: cache prepared SQLiteStatement in SQLiteIDBCursor
+ https://bugs.webkit.org/show_bug.cgi?id=201548
+
+ Reviewed by Alex Christensen.
+
+ This should be a performance improvement as we don't compile the same SQLiteStatement everytime it is used.
+
+ No new tests, no behavior change.
+
+ * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+ (WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
+ * Modules/indexeddb/server/SQLiteIDBCursor.h:
+
2019-09-10 Youenn Fablet <you...@apple.com>
RTCPeerConnection can only be instantiated in documents
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (249728 => 249729)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp 2019-09-10 19:07:21 UTC (rev 249728)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp 2019-09-10 19:42:30 UTC (rev 249729)
@@ -472,20 +472,24 @@
return FetchResult::Failure;
}
- SQLiteStatement objectStoreStatement(m_statement->database(), "SELECT value FROM Records WHERE key = CAST(? AS TEXT) and objectStoreID = ?;");
+ if (!m_cachedObjectStoreStatement || m_cachedObjectStoreStatement->reset() != SQLITE_OK) {
+ m_cachedObjectStoreStatement = makeUnique<SQLiteStatement>(m_statement->database(), "SELECT value FROM Records WHERE key = CAST(? AS TEXT) and objectStoreID = ?;");
+ if (m_cachedObjectStoreStatement->prepare() != SQLITE_OK)
+ m_cachedObjectStoreStatement = nullptr;
+ }
- if (objectStoreStatement.prepare() != SQLITE_OK
- || objectStoreStatement.bindBlob(1, keyData.data(), keyData.size()) != SQLITE_OK
- || objectStoreStatement.bindInt64(2, m_objectStoreID) != SQLITE_OK) {
+ if (!m_cachedObjectStoreStatement
+ || m_cachedObjectStoreStatement->bindBlob(1, keyData.data(), keyData.size()) != SQLITE_OK
+ || m_cachedObjectStoreStatement->bindInt64(2, m_objectStoreID) != SQLITE_OK) {
LOG_ERROR("Could not create index cursor statement into object store records (%i) '%s'", m_statement->database().lastError(), m_statement->database().lastErrorMsg());
markAsErrored(record);
return FetchResult::Failure;
}
- int result = objectStoreStatement.step();
+ int result = m_cachedObjectStoreStatement->step();
if (result == SQLITE_ROW) {
- objectStoreStatement.getColumnBlobAsVector(0, keyData);
+ m_cachedObjectStoreStatement->getColumnBlobAsVector(0, keyData);
record.record.value = makeUnique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)));
} else if (result == SQLITE_DONE) {
// This indicates that the record we're trying to retrieve has been removed from the object store.
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h (249728 => 249729)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h 2019-09-10 19:07:21 UTC (rev 249728)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h 2019-09-10 19:42:30 UTC (rev 249729)
@@ -123,6 +123,8 @@
IDBKeyData m_currentKeyForUniqueness;
std::unique_ptr<SQLiteStatement> m_statement;
+ std::unique_ptr<SQLiteStatement> m_cachedObjectStoreStatement;
+
bool m_statementNeedsReset { true };
int64_t m_boundID { 0 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes