From abf140591fb166f6fe7e9e788c6e3f1b51a54ef7 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Mon, 31 Aug 2026 08:03:02 +0200 Subject: [PATCH] =?UTF-8?q?Avoid=200(N=C2=B2)=20in=20Sasquatch=20writer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Engine/Include/Engine/Sasquatch/Sasquatch.hpp | 5 +++++ Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp | 10 +++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp b/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp index 674d8ed..47f06dc 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp @@ -107,6 +107,11 @@ class SasquatchWriter */ std::size_t m_prefetchedUpTo; + /** + * Current write position in the data region + */ + std::size_t m_currentDataOffset; + /** * The Sasquatch file being written, mapped at its final size */ diff --git a/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp b/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp index 2f5aad5..1ed6a21 100644 --- a/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp +++ b/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp @@ -20,6 +20,7 @@ SasquatchWriter::SasquatchWriter(const File& p_file, const std::size_t p_totalHardReferencesBytes): m_assetCount(p_assetCount), m_prefetchedUpTo(0), + m_currentDataOffset(sizeof(SasquatchHeader) + m_assetCount * sizeof(SasquatchEntry)), m_file(p_file, sizeof(SasquatchHeader) + m_assetCount * sizeof(SasquatchEntry) + p_totalFlatbufferBytes + p_totalHardReferencesBytes) @@ -63,13 +64,7 @@ void SasquatchWriter::WriteAsset(const UUID& p_uuid, "SasquatchWriter can only hold {} assets", m_assetCount); - const std::size_t offset = std::accumulate(m_entries.begin(), - m_entries.end(), - sizeof(SasquatchHeader) + m_assetCount * sizeof(SasquatchEntry), - [](const std::size_t p_value, const SasquatchEntry& p_entry) - { - return p_value + p_entry.m_assetSize + p_entry.m_hardReferencesSize; - }); + const std::size_t offset = m_currentDataOffset; const eastl::span data = m_file.GetData(); ASSERT(EngineAssertHandler, @@ -102,6 +97,7 @@ void SasquatchWriter::WriteAsset(const UUID& p_uuid, UUID::UUID_BYTE_SIZE); } + m_currentDataOffset += entry.m_assetSize + entry.m_hardReferencesSize; m_entries.push_back(entry); }