Commit 68d1ff85 authored by Chen Bill's avatar Chen Bill Committed by GitHub

improve loop condition in ReadDB (#2881)

parent fb6814a8
...@@ -18,10 +18,9 @@ bool DataManager::ReadDB(sqlite3* pDB) { ...@@ -18,10 +18,9 @@ bool DataManager::ReadDB(sqlite3* pDB) {
if (sqlite3_prepare_v2(pDB, sql, -1, &pStmt, nullptr) != SQLITE_OK) if (sqlite3_prepare_v2(pDB, sql, -1, &pStmt, nullptr) != SQLITE_OK)
return Error(pDB, pStmt); return Error(pDB, pStmt);
wchar_t strBuffer[4096]; wchar_t strBuffer[4096];
int step = 0; for (int step = sqlite3_step(pStmt); step != SQLITE_DONE; step = sqlite3_step(pStmt)) {
do { if (step != SQLITE_ROW)
step = sqlite3_step(pStmt); return Error(pDB, pStmt);
if (step == SQLITE_ROW) {
uint32_t code = static_cast<uint32_t>(sqlite3_column_int64(pStmt, 0)); uint32_t code = static_cast<uint32_t>(sqlite3_column_int64(pStmt, 0));
auto& cd = _datas[code]; auto& cd = _datas[code];
cd.code = code; cd.code = code;
...@@ -62,9 +61,6 @@ bool DataManager::ReadDB(sqlite3* pDB) { ...@@ -62,9 +61,6 @@ bool DataManager::ReadDB(sqlite3* pDB) {
} }
} }
} }
else if (step != SQLITE_DONE)
return Error(pDB, pStmt);
} while (step == SQLITE_ROW);
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
for (const auto& entry : extra_setcode) { for (const auto& entry : extra_setcode) {
const auto& code = entry.first; const auto& code = entry.first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment