CSeedling: Make skNeedleLocators an array of std::string_view

Makes the strings non-allocating. This also eliminates 12 runtime static
constructors that need to execute on program start.
This commit is contained in:
Lioncash 2019-09-28 20:22:29 -04:00
parent 3f743d5c9f
commit 6ad5de497f
1 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@
namespace urde::MP1 { namespace urde::MP1 {
namespace { namespace {
const std::array<std::array<std::string, 6>, 2> skNeedleLocators{{ constexpr std::array<std::array<std::string_view, 6>, 2> skNeedleLocators{{
{ {
"A_spike1_LCTR_SDK", "A_spike1_LCTR_SDK",
"A_spike2_LCTR_SDK", "A_spike2_LCTR_SDK",
@ -114,7 +114,7 @@ void CSeedling::Render(const CStateManager& mgr) const {
flags.x2_flags = 3; flags.x2_flags = 3;
flags.x4_color = zeus::skWhite; flags.x4_color = zeus::skWhite;
for (const std::string& sv : skNeedleLocators[index]) { for (const std::string_view sv : skNeedleLocators[index]) {
x6bc_spikeData->Render(mgr, GetLctrTransform(sv), x90_actorLights.get(), flags); x6bc_spikeData->Render(mgr, GetLctrTransform(sv), x90_actorLights.get(), flags);
} }
} }
@ -210,7 +210,7 @@ bool CSeedling::ShouldAttack(CStateManager& mgr, float) {
void CSeedling::LaunchNeedles(CStateManager& mgr) { void CSeedling::LaunchNeedles(CStateManager& mgr) {
const auto& needleLocators = skNeedleLocators[size_t(x722_25_curNeedleCluster)]; const auto& needleLocators = skNeedleLocators[size_t(x722_25_curNeedleCluster)];
for (const std::string& needle : needleLocators) { for (const std::string_view needle : needleLocators) {
LaunchProjectile(GetLctrTransform(needle), mgr, int(needleLocators.size()), EProjectileAttrib::None, true, {}, LaunchProjectile(GetLctrTransform(needle), mgr, int(needleLocators.size()), EProjectileAttrib::None, true, {},
0xFFFF, false, GetModelData()->GetScale()); 0xFFFF, false, GetModelData()->GetScale());
} }