Bug 1318282 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in storage/.
MozReview-Commit-ID: HuudUDUcQYu
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -1414,25 +1414,25 @@ Connection::initializeClone(Connection*
"cache_size",
"temp_store",
"foreign_keys",
"journal_size_limit",
"synchronous",
"wal_autocheckpoint",
"busy_timeout"
};
- for (uint32_t i = 0; i < ArrayLength(pragmas); ++i) {
+ for (auto& pragma : pragmas) {
// Read-only connections just need cache_size and temp_store pragmas.
- if (aReadOnly && ::strcmp(pragmas[i], "cache_size") != 0 &&
- ::strcmp(pragmas[i], "temp_store") != 0) {
+ if (aReadOnly && ::strcmp(pragma, "cache_size") != 0 &&
+ ::strcmp(pragma, "temp_store") != 0) {
continue;
}
nsAutoCString pragmaQuery("PRAGMA ");
- pragmaQuery.Append(pragmas[i]);
+ pragmaQuery.Append(pragma);
nsCOMPtr<mozIStorageStatement> stmt;
rv = CreateStatement(pragmaQuery, getter_AddRefs(stmt));
MOZ_ASSERT(NS_SUCCEEDED(rv));
bool hasResult = false;
if (stmt && NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
pragmaQuery.AppendLiteral(" = ");
pragmaQuery.AppendInt(stmt->AsInt32(0));
rv = aClone->ExecuteSimpleSQL(pragmaQuery);
@@ -1976,18 +1976,18 @@ Connection::SetGrowthIncrement(int32_t a
return NS_OK;
}
NS_IMETHODIMP
Connection::EnableModule(const nsACString& aModuleName)
{
if (!mDBConn) return NS_ERROR_NOT_INITIALIZED;
- for (size_t i = 0; i < ArrayLength(gModules); i++) {
- struct Module* m = &gModules[i];
+ for (auto& gModule : gModules) {
+ struct Module* m = &gModule;
if (aModuleName.Equals(m->name)) {
int srv = m->registerFunc(mDBConn, m->name);
if (srv != SQLITE_OK)
return convertResultCode(srv);
return NS_OK;
}
}
--- a/storage/test/test_mutex.cpp
+++ b/storage/test/test_mutex.cpp
@@ -17,21 +17,21 @@ using namespace mozilla::storage;
void
test_AutoLock()
{
int lockTypes[] = {
SQLITE_MUTEX_FAST,
SQLITE_MUTEX_RECURSIVE,
};
- for (size_t i = 0; i < ArrayLength(lockTypes); i++) {
+ for (int lockType : lockTypes) {
// Get our test mutex (we have to allocate a SQLite mutex of the right type
// too!).
SQLiteMutex mutex("TestMutex");
- sqlite3_mutex *inner = sqlite3_mutex_alloc(lockTypes[i]);
+ sqlite3_mutex *inner = sqlite3_mutex_alloc(lockType);
do_check_true(inner);
mutex.initWithMutex(inner);
// And test that our automatic locking wrapper works as expected.
mutex.assertNotCurrentThreadOwns();
{
SQLiteMutexAutoLock lockedScope(mutex);
mutex.assertCurrentThreadOwns();
@@ -45,21 +45,21 @@ test_AutoLock()
void
test_AutoUnlock()
{
int lockTypes[] = {
SQLITE_MUTEX_FAST,
SQLITE_MUTEX_RECURSIVE,
};
- for (size_t i = 0; i < ArrayLength(lockTypes); i++) {
+ for (int lockType : lockTypes) {
// Get our test mutex (we have to allocate a SQLite mutex of the right type
// too!).
SQLiteMutex mutex("TestMutex");
- sqlite3_mutex *inner = sqlite3_mutex_alloc(lockTypes[i]);
+ sqlite3_mutex *inner = sqlite3_mutex_alloc(lockType);
do_check_true(inner);
mutex.initWithMutex(inner);
// And test that our automatic unlocking wrapper works as expected.
{
SQLiteMutexAutoLock lockedScope(mutex);
{