chore: Remove unnecessary heap allocations (#1478)

This commit is contained in:
jadebenn
2024-02-25 19:35:07 -06:00
committed by GitHub
parent 192c8cf974
commit 95d687846a
3 changed files with 23 additions and 42 deletions

View File

@@ -243,13 +243,13 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
echo.uiBehaviorHandle = entry.handle;
echo.uiSkillHandle = this->skillUId;
auto* bitStream = new RakNet::BitStream();
RakNet::BitStream bitStream{};
// Calculate sync
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
entry.behavior->SyncCalculation(this, &bitStream, entry.branchContext);
if (!clientInitalized) {
echo.sBitStream.assign(reinterpret_cast<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
echo.sBitStream.assign(reinterpret_cast<char*>(bitStream.GetData()), bitStream.GetNumberOfBytesUsed());
// Write message
RakNet::BitStream message;
@@ -262,8 +262,6 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
}
ExecuteUpdates();
delete bitStream;
}
std::vector<BehaviorSyncEntry> valid;