mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-31 17:08:45 +01:00
AUP3: Use persistent prepared statements
SqliteSampleBlock now uses already prepared SQL statements for all DB usage. This means that the statements won't have to be compiled each time they are used.
This commit is contained in:
@@ -24,6 +24,7 @@ Paul Licameli split from AudacityProject.h
|
||||
|
||||
struct sqlite3;
|
||||
struct sqlite3_context;
|
||||
struct sqlite3_stmt;
|
||||
struct sqlite3_value;
|
||||
|
||||
class AudacityProject;
|
||||
@@ -159,7 +160,18 @@ private:
|
||||
|
||||
sqlite3 *OpenDB(FilePath fileName = {});
|
||||
bool CloseDB();
|
||||
bool DeleteDB();
|
||||
|
||||
enum StatementID
|
||||
{
|
||||
GetSamples,
|
||||
GetSummary256,
|
||||
GetSummary64k,
|
||||
LoadSampleBlock,
|
||||
InsertSampleBlock,
|
||||
DeleteSampleBlock
|
||||
};
|
||||
void Prepare(enum StatementID id, const char *sql);
|
||||
sqlite3_stmt *GetStatement(enum StatementID id);
|
||||
|
||||
bool Query(const char *sql, const ExecCB &callback);
|
||||
|
||||
@@ -233,6 +245,8 @@ private:
|
||||
std::atomic< std::uint64_t > mCheckpointWaitingPages{ 0 };
|
||||
std::atomic< std::uint64_t > mCheckpointCurrentPages{ 0 };
|
||||
|
||||
std::map<enum StatementID, sqlite3_stmt *> mStatements;
|
||||
|
||||
friend SqliteSampleBlock;
|
||||
friend AutoCommitTransaction;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user