From 5ff100fdd13f6c658128891cb72ea4c6b941de65 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 24 Feb 2020 03:32:30 -0500 Subject: [PATCH] DNAMP1/ScriptObjects: Convert SCRIPT_OBJECT_DB into a std::array Now that all elements of the std::vector would otherwise be constexpr, we can use a std::array here instead, given they're all able to deterministically be available at compile-time. This gets rid of a runtime static heap allocation at program start. --- DataSpec/DNAMP1/ScriptObjects/IScriptObject.cpp | 2 +- DataSpec/DNAMP1/ScriptObjects/ScriptTypes.hpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DataSpec/DNAMP1/ScriptObjects/IScriptObject.cpp b/DataSpec/DNAMP1/ScriptObjects/IScriptObject.cpp index e8b41ddd1..f29c32671 100644 --- a/DataSpec/DNAMP1/ScriptObjects/IScriptObject.cpp +++ b/DataSpec/DNAMP1/ScriptObjects/IScriptObject.cpp @@ -284,7 +284,7 @@ constexpr ScriptObjectSpec EnergyBallEnt = {0x8B, []() -> IScriptObject* { retur } // Anonymous namespace } // namespace priv -const std::vector SCRIPT_OBJECT_DB = { +const ScriptObjectDBArray SCRIPT_OBJECT_DB = { &priv::AIJumpPointEnt, &priv::AIKeyframeEnt, &priv::ActorEnt, diff --git a/DataSpec/DNAMP1/ScriptObjects/ScriptTypes.hpp b/DataSpec/DNAMP1/ScriptObjects/ScriptTypes.hpp index 127f1c865..a354c9430 100644 --- a/DataSpec/DNAMP1/ScriptObjects/ScriptTypes.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/ScriptTypes.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -12,5 +12,7 @@ struct ScriptObjectSpec { IScriptObject* (*a)(); }; -extern const std::vector SCRIPT_OBJECT_DB; +using ScriptObjectDBArray = std::array; + +extern const ScriptObjectDBArray SCRIPT_OBJECT_DB; } // namespace DataSpec::DNAMP1