Bug 452836 - Optimize calls to sqlite3_prepare_v2

This makes sqlite not copy the sql string when preparing it, saving us a string
copy every time.
r=bholley
This commit is contained in:
Shawn Wilsher 2008-08-29 17:19:23 -04:00
Родитель cfba414480
Коммит 6dea9a020c
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -114,8 +114,11 @@ mozStorageStatement::Initialize(mozStorageConnection *aDBConnection,
NS_ENSURE_TRUE(db != nsnull, NS_ERROR_NULL_POINTER);
int srv;
srv = sqlite3_prepare_v2(db, nsPromiseFlatCString(aSQLStatement).get(),
aSQLStatement.Length(), &mDBStatement, NULL);
// We pass Length() + 1 to sqlite because it checks if the sql string it is
// given contains '\0' at the specified length. If it does contain '\0', it
// will not copy the string.
srv = sqlite3_prepare_v2(db, PromiseFlatCString(aSQLStatement).get(),
aSQLStatement.Length() + 1, &mDBStatement, NULL);
if (srv != SQLITE_OK) {
#ifdef PR_LOGGING
PR_LOG(gStorageLog, PR_LOG_ERROR, ("Sqlite statement prepare error: %d '%s'", srv, sqlite3_errmsg(db)));