From e129492394dd13e77bfacf2424b97dbcb3b3255f Mon Sep 17 00:00:00 2001 From: chrispader Date: Thu, 23 Jul 2026 16:06:54 +0200 Subject: [PATCH 1/4] refactor: move constexpr to upper scope --- .../cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp index 81aedb33..fbd9cb6e 100644 --- a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp +++ b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp @@ -10,6 +10,8 @@ namespace margelo::nitro::rnnitrosqlite { namespace { + constexpr size_t nodePadding = 24; + /** * Compute the approximate external memory size of a single result row. * This includes: @@ -18,7 +20,6 @@ namespace { */ size_t getRowExternalMemorySize(const SQLiteQueryResultRow& row) { size_t bucketMemory = row.bucket_count() * sizeof(void*); - constexpr size_t nodePadding = 24; size_t nodesMemory = row.size() * (sizeof(std::pair) + nodePadding); return bucketMemory + nodesMemory; } From 99fb459a0b408aff1fb9795f7d68935bc3f73378 Mon Sep 17 00:00:00 2001 From: chrispader Date: Thu, 23 Jul 2026 16:07:03 +0200 Subject: [PATCH 2/4] fix: metadata size calculation --- .../cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp index fbd9cb6e..70ad447e 100644 --- a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp +++ b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp @@ -50,10 +50,10 @@ namespace { * - Metadata contents, especially the `name` string on each metadata entry. */ size_t getMetadataExternalMemorySize(const SQLiteQueryTableMetadata& metadata) { - size_t size = 0; + size_t size = metadata.bucket_count() * sizeof(void*); + size += metadata.size() * (sizeof(SQLiteQueryTableMetadata::value_type) + nodePadding); for (const auto& [columnName, columnMeta] : metadata) { - size += columnName.capacity(); size += columnMeta.name.capacity(); } From 7bc0dbe30673c6644a0cabdedd4a577eb790aaa2 Mon Sep 17 00:00:00 2001 From: chrispader Date: Thu, 23 Jul 2026 16:07:10 +0200 Subject: [PATCH 3/4] fix: std::move metadata object --- .../cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp index f70c6063..144f3f7e 100644 --- a/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp +++ b/packages/react-native-nitro-sqlite/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp @@ -13,7 +13,7 @@ class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec { HybridNitroSQLiteQueryResult() : HybridObject(TAG) {} HybridNitroSQLiteQueryResult(SQLiteQueryResults results, std::optional insertId, double rowsAffected, std::optional metadata) - : HybridObject(TAG), _insertId(insertId), _rowsAffected(rowsAffected), _results(std::move(results)), _metadata(metadata) {} + : HybridObject(TAG), _insertId(insertId), _rowsAffected(rowsAffected), _results(std::move(results)), _metadata(std::move(metadata)) {} private: std::optional _insertId; From 5a854e1c94849e7cbc61c3c05e7034a97014d228 Mon Sep 17 00:00:00 2001 From: chrispader Date: Thu, 23 Jul 2026 16:07:52 +0200 Subject: [PATCH 4/4] style: format --- packages/react-native-nitro-sqlite/cpp/operations.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/react-native-nitro-sqlite/cpp/operations.cpp b/packages/react-native-nitro-sqlite/cpp/operations.cpp index 289defe5..836ec30d 100644 --- a/packages/react-native-nitro-sqlite/cpp/operations.cpp +++ b/packages/react-native-nitro-sqlite/cpp/operations.cpp @@ -25,7 +25,6 @@ using namespace margelo::nitro::rnnitrosqlite; namespace margelo::rnnitrosqlite { - static constexpr double kInt64MinAsDouble = static_cast(std::numeric_limits::min()); static constexpr double kInt64UpperBoundAsDouble = -kInt64MinAsDouble; @@ -128,8 +127,7 @@ void bindStatement(sqlite3_stmt* statement, const SQLiteQueryParams& values) { } else if (std::holds_alternative(value)) { // Bind whole numbers as INTEGER so vec0 rowid/pk/partition (which reject REAL) work; SQLite still coerces to REAL for REAL columns. double doubleValue = std::get(value); - if (std::trunc(doubleValue) == doubleValue && doubleValue >= kInt64MinAsDouble && - doubleValue < kInt64UpperBoundAsDouble) { + if (std::trunc(doubleValue) == doubleValue && doubleValue >= kInt64MinAsDouble && doubleValue < kInt64UpperBoundAsDouble) { sqlite3_bind_int64(statement, sqliteIndex, static_cast(doubleValue)); } else { sqlite3_bind_double(statement, sqliteIndex, doubleValue);