From 75bccad80b2e6ce9044aff402c53085988db9b83 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Thu, 31 Oct 2024 11:58:20 +0100 Subject: [PATCH] Minor improvements --- cpp/bridge.cpp | 17 +++++++++-------- cpp/bridge.h | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index 78129e6a..65e07efc 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -794,7 +794,7 @@ opsqlite_execute_raw(std::string const &dbName, std::string const &query, i++; } - results->emplace_back(row); + results->emplace_back(row); break; } @@ -860,16 +860,17 @@ std::string operation_to_string(int operation_type) { } } -void update_callback(void *dbName, int operation_type, char const *database, - char const *table, sqlite3_int64 rowid) { +void update_callback(void *dbName, int operation_type, + [[maybe_unused]] char const *database, char const *table, + sqlite3_int64 row_id) { std::string &strDbName = *(static_cast(dbName)); auto callback = updateCallbackMap[strDbName]; callback(strDbName, std::string(table), operation_to_string(operation_type), - static_cast(rowid)); + static_cast(row_id)); } BridgeResult opsqlite_register_update_hook(std::string const &dbName, - UpdateCallback const callback) { + UpdateCallback const &callback) { check_db_open(dbName); sqlite3 *db = dbMap[dbName]; @@ -908,7 +909,7 @@ int commit_callback(void *dbName) { } BridgeResult opsqlite_register_commit_hook(std::string const &dbName, - CommitCallback const callback) { + CommitCallback const &callback) { check_db_open(dbName); sqlite3 *db = dbMap[dbName]; @@ -944,7 +945,7 @@ void rollback_callback(void *dbName) { } BridgeResult opsqlite_register_rollback_hook(std::string const &dbName, - RollbackCallback const callback) { + RollbackCallback const &callback) { check_db_open(dbName); sqlite3 *db = dbMap[dbName]; @@ -1019,7 +1020,7 @@ BatchResult opsqlite_execute_batch(std::string &name, int affectedRows = 0; opsqlite_execute(name, "BEGIN EXCLUSIVE TRANSACTION", nullptr); for (int i = 0; i < commandCount; i++) { - auto command = commands->at(i); + const auto &command = commands->at(i); // We do not provide a datastructure to receive query data because we // don't need/want to handle this results in a batch execution auto result = opsqlite_execute(name, command.sql, command.params.get()); diff --git a/cpp/bridge.h b/cpp/bridge.h index 012a6db1..b6d9bc6d 100644 --- a/cpp/bridge.h +++ b/cpp/bridge.h @@ -65,13 +65,13 @@ BridgeResult opsqlite_execute_raw(std::string const &dbName, void opsqlite_close_all(); BridgeResult opsqlite_register_update_hook(std::string const &dbName, - UpdateCallback callback); + const UpdateCallback& callback); BridgeResult opsqlite_deregister_update_hook(std::string const &dbName); BridgeResult opsqlite_register_commit_hook(std::string const &dbName, - CommitCallback callback); + const CommitCallback& callback); BridgeResult opsqlite_deregister_commit_hook(std::string const &dbName); BridgeResult opsqlite_register_rollback_hook(std::string const &dbName, - RollbackCallback callback); + const RollbackCallback& callback); BridgeResult opsqlite_deregister_rollback_hook(std::string const &dbName); sqlite3_stmt *opsqlite_prepare_statement(std::string const &dbName,