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.
This commit is contained in:
Lioncash 2020-02-24 03:32:30 -05:00
parent 2ec236fc45
commit 5ff100fdd1
2 changed files with 5 additions and 3 deletions

View File

@ -284,7 +284,7 @@ constexpr ScriptObjectSpec EnergyBallEnt = {0x8B, []() -> IScriptObject* { retur
} // Anonymous namespace
} // namespace priv
const std::vector<const struct ScriptObjectSpec*> SCRIPT_OBJECT_DB = {
const ScriptObjectDBArray SCRIPT_OBJECT_DB = {
&priv::AIJumpPointEnt,
&priv::AIKeyframeEnt,
&priv::ActorEnt,

View File

@ -1,6 +1,6 @@
#pragma once
#include <vector>
#include <array>
#include <athena/Types.hpp>
@ -12,5 +12,7 @@ struct ScriptObjectSpec {
IScriptObject* (*a)();
};
extern const std::vector<const struct ScriptObjectSpec*> SCRIPT_OBJECT_DB;
using ScriptObjectDBArray = std::array<const ScriptObjectSpec*, 127>;
extern const ScriptObjectDBArray SCRIPT_OBJECT_DB;
} // namespace DataSpec::DNAMP1