Ignore:
Timestamp:
Apr 5, 2015, 1:44:35 PM (10 years ago)
Author:
[email protected]
Message:

Use constants of sqlite3 directly for status of SQL result in webdatabase
https://bugs.webkit.org/show_bug.cgi?id=143329

Patch by Gyuyoung Kim <[email protected]> on 2015-04-05
Reviewed by Darin Adler.

Source/WebCore:

In webdatabase, it has used own constant vairables as well as using sqlite3 constants directly.
It causes to use if~else statement which consumes more cpu cycles compared to switch~case. This
patch makes to use constants of sqlite3. Additionally if~else statment is changed to switch~case
to save cpu cycles.

No new tests, no behavior changes.

  • Modules/webdatabase/Database.cpp:

(WebCore::Database::performGetTableNames):

  • Modules/webdatabase/DatabaseBackendBase.cpp:

(WebCore::retrieveTextResultFromDatabase):
(WebCore::setTextValueInDatabase):
(WebCore::DatabaseBackendBase::incrementalVacuumIfNeeded):

  • Modules/webdatabase/DatabaseTracker.cpp:

(WebCore::DatabaseTracker::hasEntryForOriginNoLock):
(WebCore::DatabaseTracker::hasEntryForDatabase):
(WebCore::DatabaseTracker::fullPathForDatabaseNoLock):
(WebCore::DatabaseTracker::origins):
(WebCore::DatabaseTracker::databaseNamesForOriginNoLock):
(WebCore::DatabaseTracker::detailsForNameAndOrigin):
(WebCore::DatabaseTracker::setDatabaseDetails):
(WebCore::DatabaseTracker::quotaForOriginNoLock):
(WebCore::DatabaseTracker::setQuota):
(WebCore::DatabaseTracker::addDatabase):
(WebCore::DatabaseTracker::deleteOrigin):
(WebCore::DatabaseTracker::deleteDatabase):
(WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
(WebCore::DatabaseTracker::deleteDatabaseFileIfEmpty):

  • Modules/webdatabase/SQLStatementBackend.cpp:

(WebCore::SQLStatementBackend::execute):

  • Modules/webdatabase/SQLStatementBackend.h:
  • Modules/webdatabase/SQLTransactionBackend.cpp:

(WebCore::SQLTransactionBackend::runCurrentStatementAndGetNextState):
Change to use a reference instead of a pointer in arguemnt of execute().

  • loader/appcache/ApplicationCacheStorage.cpp:

(WebCore::ApplicationCacheStorage::loadCacheGroup):
(WebCore::ApplicationCacheStorage::loadManifestHostHashes):
(WebCore::ApplicationCacheStorage::cacheGroupForURL):
(WebCore::ApplicationCacheStorage::fallbackCacheGroupForURL):
(WebCore::ApplicationCacheStorage::calculateQuotaForOrigin):
(WebCore::ApplicationCacheStorage::calculateUsageForOrigin):
(WebCore::ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache):
(WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin):
(WebCore::ApplicationCacheStorage::verifySchemaVersion):
(WebCore::ApplicationCacheStorage::store):
(WebCore::ApplicationCacheStorage::storeUpdatedType):
(WebCore::ApplicationCacheStorage::ensureOriginRecord):
(WebCore::ApplicationCacheStorage::storeNewestCache):
(WebCore::ApplicationCacheStorage::loadCache):
(WebCore::ApplicationCacheStorage::remove):
(WebCore::ApplicationCacheStorage::getManifestURLs):
(WebCore::ApplicationCacheStorage::cacheGroupSize):
(WebCore::ApplicationCacheStorage::deleteCacheGroupRecord):
(WebCore::ApplicationCacheStorage::checkForMaxSizeReached):
(WebCore::ApplicationCacheStorage::checkForDeletedResources):
(WebCore::ApplicationCacheStorage::flatFileAreaSize):

  • loader/icon/IconDatabase.cpp:

(WebCore::IconDatabase::checkIntegrity):
(WebCore::IconDatabase::performURLImport):
(WebCore::IconDatabase::pruneUnretainedIcons):
(WebCore::readySQLiteStatement):
(WebCore::IconDatabase::setIconIDForPageURLInSQLDatabase):
(WebCore::IconDatabase::removePageURLFromSQLDatabase):
(WebCore::IconDatabase::getIconIDForIconURLFromSQLDatabase):
(WebCore::IconDatabase::addIconURLToSQLDatabase):
(WebCore::IconDatabase::getImageDataForIconURLFromSQLDatabase):
(WebCore::IconDatabase::removeIconFromSQLDatabase):
(WebCore::IconDatabase::writeIconSnapshotToSQLDatabase):

  • platform/sql/SQLiteDatabase.cpp:

(WebCore::SQLiteDatabase::setMaximumSize):

  • platform/sql/SQLiteDatabase.h:
  • platform/sql/SQLiteFileSystem.cpp:

(WebCore::SQLiteFileSystem::getFileNameForNewDatabase):

  • platform/sql/SQLiteStatement.cpp:

(WebCore::SQLiteStatement::step):
(WebCore::SQLiteStatement::returnIntResults):
(WebCore::SQLiteStatement::returnInt64Results):

Source/WebKit:

In webdatabase, it has used own constants vairables as well as using sqlite3 constants directly.
It causes to use if~else statement which consumes more cpu cycles compared to switch~case. This
patch makes to use constants of sqlite3.

  • Storage/StorageAreaSync.cpp:

(WebCore::StorageAreaSync::performImport):
(WebCore::StorageAreaSync::sync):
(WebCore::StorageAreaSync::deleteEmptyDatabase):

  • Storage/StorageTracker.cpp:

(WebCore::StorageTracker::syncImportOriginIdentifiers):
(WebCore::StorageTracker::syncSetOriginDetails):
(WebCore::StorageTracker::syncDeleteAllOrigins):
(WebCore::StorageTracker::syncDeleteOrigin):
(WebCore::StorageTracker::databasePathForOrigin):

  • WebKit.vcxproj/WebKit/WebKitCommon.props: Add sqlite include path.

Source/WebKit2:

In webdatabase, it has used own constant variables as well as using sqlite3 constants directly.
If sqlite3 constants are changed in the library, we should modify many files as well. Besides
it can cause to use if~else statement which consumes more cpu cycles compared to switch~case.

  • DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:

(WebKit::SQLiteIDBCursor::createSQLiteStatement):
(WebKit::SQLiteIDBCursor::resetAndRebindStatement):
(WebKit::SQLiteIDBCursor::bindArguments):
(WebKit::SQLiteIDBCursor::internalAdvanceOnce):

  • DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:

(WebKit::createOrMigrateRecordsTableIfNecessary):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::extractExistingMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::changeDatabaseVersion):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createIndex):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteIndex):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::generateKeyNumber):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::updateKeyGeneratorNumber):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::keyExistsInObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::putRecord):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::uncheckedPutIndexRecord):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteRecord):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRecordFromObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRangeRecordFromObjectStore):

  • NetworkProcess/cache/NetworkCacheStatistics.cpp:

(WebKit::NetworkCache::executeSQLStatement):
(WebKit::NetworkCache::Statistics::initialize):
(WebKit::NetworkCache::Statistics::queryWasEverRequested):
(WebKit::NetworkCache::Statistics::addHashesToDatabase):
(WebKit::NetworkCache::Statistics::addStoreDecisionsToDatabase):

  • UIProcess/Storage/LocalStorageDatabase.cpp:

(WebKit::LocalStorageDatabase::importItems):
(WebKit::LocalStorageDatabase::updateDatabaseWithChangedItems):
(WebKit::LocalStorageDatabase::databaseIsEmpty):

  • UIProcess/Storage/LocalStorageDatabaseTracker.cpp:

(WebKit::LocalStorageDatabaseTracker::deleteAllDatabases):
(WebKit::LocalStorageDatabaseTracker::importOriginIdentifiers):
(WebKit::LocalStorageDatabaseTracker::addDatabaseWithOriginIdentifier):
(WebKit::LocalStorageDatabaseTracker::removeDatabaseWithOriginIdentifier):
(WebKit::LocalStorageDatabaseTracker::pathForDatabaseWithOriginIdentifier):

  • WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.cpp:

(webkitSoupCookieJarSqliteLoad):
(webkitSoupCookieJarSqliteInsertCookie):
(webkitSoupCookieJarSqliteDeleteCookie):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/Storage/StorageTracker.cpp

    r177814 r182365  
    210210
    211211            SQLiteStatement statement(m_database, "SELECT origin FROM Origins");
    212             if (statement.prepare() != SQLResultOk) {
     212            if (statement.prepare() != SQLITE_OK) {
    213213                LOG_ERROR("Failed to prepare statement.");
    214214                return;
     
    219219            {
    220220                MutexLocker lockOrigins(m_originSetMutex);
    221                 while ((result = statement.step()) == SQLResultRow)
     221                while ((result = statement.step()) == SQLITE_ROW)
    222222                    m_originSet.add(statement.getColumnText(0).isolatedCopy());
    223223            }
    224224           
    225             if (result != SQLResultDone) {
     225            if (result != SQLITE_DONE) {
    226226                LOG_ERROR("Failed to read in all origins from the database.");
    227227                return;
     
    346346
    347347    SQLiteStatement statement(m_database, "INSERT INTO Origins VALUES (?, ?)");
    348     if (statement.prepare() != SQLResultOk) {
     348    if (statement.prepare() != SQLITE_OK) {
    349349        LOG_ERROR("Unable to establish origin '%s' in the tracker", originIdentifier.ascii().data());
    350350        return;
     
    354354    statement.bindText(2, databaseFile);
    355355   
    356     if (statement.step() != SQLResultDone)
     356    if (statement.step() != SQLITE_DONE)
    357357        LOG_ERROR("Unable to establish origin '%s' in the tracker", originIdentifier.ascii().data());
    358358
     
    425425   
    426426    SQLiteStatement statement(m_database, "SELECT origin, path FROM Origins");
    427     if (statement.prepare() != SQLResultOk) {
     427    if (statement.prepare() != SQLITE_OK) {
    428428        LOG_ERROR("Failed to prepare statement.");
    429429        return;
     
    431431   
    432432    int result;
    433     while ((result = statement.step()) == SQLResultRow) {
     433    while ((result = statement.step()) == SQLITE_ROW) {
    434434        if (!canDeleteOrigin(statement.getColumnText(0)))
    435435            continue;
     
    444444    }
    445445   
    446     if (result != SQLResultDone)
     446    if (result != SQLITE_DONE)
    447447        LOG_ERROR("Failed to read in all origins from the database.");
    448448
     
    462462            return;
    463463        SQLiteStatement deleteStatement(m_database, "DELETE FROM Origins");
    464         if (deleteStatement.prepare() != SQLResultOk) {
     464        if (deleteStatement.prepare() != SQLITE_OK) {
    465465            LOG_ERROR("Unable to prepare deletion of all origins");
    466466            return;
     
    536536   
    537537    SQLiteStatement deleteStatement(m_database, "DELETE FROM Origins where origin=?");
    538     if (deleteStatement.prepare() != SQLResultOk) {
     538    if (deleteStatement.prepare() != SQLITE_OK) {
    539539        LOG_ERROR("Unable to prepare deletion of origin '%s'", originIdentifier.ascii().data());
    540540        return;
     
    631631
    632632    SQLiteStatement pathStatement(m_database, "SELECT path FROM Origins WHERE origin=?");
    633     if (pathStatement.prepare() != SQLResultOk) {
     633    if (pathStatement.prepare() != SQLITE_OK) {
    634634        LOG_ERROR("Unable to prepare selection of path for origin '%s'", originIdentifier.ascii().data());
    635635        return String();
     
    637637    pathStatement.bindText(1, originIdentifier);
    638638    int result = pathStatement.step();
    639     if (result != SQLResultRow)
     639    if (result != SQLITE_ROW)
    640640        return String();
    641641
Note: See TracChangeset for help on using the changeset viewer.