Explorar o código

perf(snapshot): use yyjson for deserialize parses (phase A)

fszontagh hai 2 meses
pai
achega
15ce1fbe0c
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      service/src/persistence/snapshot.cpp

+ 4 - 3
service/src/persistence/snapshot.cpp

@@ -1,5 +1,6 @@
 #include "snapshot.hpp"
 #include "wal.hpp"
+#include "../json_parse.hpp"
 
 #include <algorithm>
 #include <atomic>
@@ -817,7 +818,7 @@ void SnapshotManager::deserializeStore(const std::vector<uint8_t>& data, MemoryS
         std::string optionsJson(reinterpret_cast<const char*>(&data[offset]), optionsLen);
         offset += optionsLen;
         try {
-            slice.options = CollectionOptions::fromJson(nlohmann::json::parse(optionsJson));
+            slice.options = CollectionOptions::fromJson(smartbotic::db::parse_to_nlohmann(optionsJson));
         } catch (const nlohmann::json::exception&) {
             // Defaults — same fallback as the pre-v1.8 path.
         }
@@ -926,7 +927,7 @@ void SnapshotManager::deserializeStore(const std::vector<uint8_t>& data, MemoryS
             std::string docJson(reinterpret_cast<const char*>(&data[off]), docLen);
             off += docLen;
             try {
-                Document doc = Document::fromJson(nlohmann::json::parse(docJson));
+                Document doc = Document::fromJson(smartbotic::db::parse_to_nlohmann(docJson));
                 store.loadDocument(collName, doc);
             } catch (const nlohmann::json::exception&) {
                 // Skip invalid document — same tolerance as pre-v1.8.
@@ -960,7 +961,7 @@ void SnapshotManager::deserializeStore(const std::vector<uint8_t>& data, MemoryS
                     std::string verJson(reinterpret_cast<const char*>(&data[off]), verLen);
                     off += verLen;
                     try {
-                        auto ver = DocumentVersion::fromJson(nlohmann::json::parse(verJson));
+                        auto ver = DocumentVersion::fromJson(smartbotic::db::parse_to_nlohmann(verJson));
                         history.push_back(std::move(ver));
                     } catch (const nlohmann::json::exception&) {
                         // Skip invalid version entry.