Mercurial > hg > orthanc
changeset 5566:8b507b1514eb find-refactoring
cache dynamic SQLite statements (imported from large-queries branch)
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 23 Apr 2024 14:37:11 +0200 |
parents | def06a42e5ef |
children | f3562c1a150d |
files | OrthancFramework/Sources/SQLite/Connection.h OrthancFramework/Sources/SQLite/StatementId.cpp OrthancFramework/Sources/SQLite/StatementId.h |
diffstat | 3 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/SQLite/Connection.h Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/Connection.h Tue Apr 23 14:37:11 2024 +0200 @@ -56,6 +56,7 @@ #endif #define SQLITE_FROM_HERE ::Orthanc::SQLite::StatementId(__ORTHANC_FILE__, __LINE__) +#define SQLITE_FROM_HERE_DYNAMIC(sql) ::Orthanc::SQLite::StatementId(__ORTHANC_FILE__, __LINE__, sql) namespace Orthanc {
--- a/OrthancFramework/Sources/SQLite/StatementId.cpp Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/StatementId.cpp Tue Apr 23 14:37:11 2024 +0200 @@ -56,12 +56,24 @@ { } + Orthanc::SQLite::StatementId::StatementId(const char *file, + int line, + const std::string& statement) : + file_(file), + line_(line), + statement_(statement) + { + } + bool StatementId::operator< (const StatementId& other) const { if (line_ != other.line_) return line_ < other.line_; - return strcmp(file_, other.file_) < 0; + if (strcmp(file_, other.file_) < 0) + return true; + + return statement_ < other.statement_; } } }
--- a/OrthancFramework/Sources/SQLite/StatementId.h Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/StatementId.h Tue Apr 23 14:37:11 2024 +0200 @@ -54,6 +54,7 @@ private: const char* file_; int line_; + std::string statement_; StatementId(); // Forbidden @@ -61,6 +62,10 @@ StatementId(const char* file, int line); + StatementId(const char* file, + int line, + const std::string& statement); + bool operator< (const StatementId& other) const; }; }