No-Intro: Improve parsing performance
Jeffrey Pfau jeffrey@endrift.com
Wed, 11 Jan 2017 23:02:27 -0800
1 files changed,
14 insertions(+),
0 deletions(-)
jump to
M
src/feature/sqlite3/no-intro.c
→
src/feature/sqlite3/no-intro.c
@@ -25,6 +25,8 @@ }
static const char createTables[] = "PRAGMA foreign_keys = ON;\n" + "PRAGMA journal_mode = MEMORY;\n" + "PRAGMA synchronous = NORMAL;\n" "CREATE TABLE IF NOT EXISTS gamedb (" "dbid INTEGER NOT NULL PRIMARY KEY ASC," "name TEXT,"@@ -100,6 +102,8 @@ if (sqlite3_prepare_v2(db->db, insertRom, -1, &romTable, NULL)) {
return false; } + size_t remainingInTransaction = 0; + while (true) { ssize_t bytesRead = vf->readline(vf, line, sizeof(line)); if (!bytesRead) {@@ -126,6 +130,13 @@ case '(':
if (!fieldName) { break; } + if (!remainingInTransaction) { + remainingInTransaction = 16; + sqlite3_exec(db->db, "BEGIN TRANSACTION;", NULL, NULL, NULL); + } else { + --remainingInTransaction; + } + if (strcmp(fieldName, "clrmamepro") == 0) { free((void*) dbType); free((void*) dbVersion);@@ -182,6 +193,9 @@ sqlite3_bind_int(romTable, 7, buffer.verified);
sqlite3_step(romTable); free((void*) buffer.romName); buffer.romName = NULL; + } + if (!remainingInTransaction) { + sqlite3_exec(db->db, "COMMIT;", NULL, NULL, NULL); } break; case '"':