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) {
if (sqlite3_prepare_v2(pDB, sql, -1, &pStmt, nullptr) != SQLITE_OK)
return Error(pDB, pStmt);
wchar_t strBuffer[4096];
int step = 0;
do {
step = sqlite3_step(pStmt);
if (step == SQLITE_ROW) {
for (int step = sqlite3_step(pStmt); step != SQLITE_DONE; step = sqlite3_step(pStmt)) {
if (step != SQLITE_ROW)
return Error(pDB, pStmt);
uint32_t code = static_cast<uint32_t>(sqlite3_column_int64(pStmt, 0));
auto& cd = _datas[code];
cd.code = code;
......@@ -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);
for (const auto& entry : extra_setcode) {
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