mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 06:27:43 +00:00
CAiFuncMap: Store std::string_view instances instead of std::string
We only make use of static string entries, so we can make use of std::string view to elide several memory allocations.
This commit is contained in:
@@ -14,7 +14,7 @@ CStateMachine::CStateMachine(CInputStream& in) {
|
||||
|
||||
for (u32 i = 0; i < stateCount; ++i) {
|
||||
std::string name = in.readString(31, false);
|
||||
CAiStateFunc func = CAi::GetStateFunc(name.c_str());
|
||||
CAiStateFunc func = CAi::GetStateFunc(name);
|
||||
x0_states.emplace_back(func, name.c_str());
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ CStateMachine::CStateMachine(CInputStream& in) {
|
||||
x0_states[i].SetTriggers(firstTrig);
|
||||
x10_triggers.resize(x10_triggers.size() + x0_states[i].GetNumTriggers());
|
||||
|
||||
for (u32 j = 0; j < x0_states[i].GetNumTriggers(); ++j) {
|
||||
u32 triggerCount = in.readUint32Big();
|
||||
u32 lastTriggerIdx = triggerCount - 1;
|
||||
for (s32 j = 0; j < x0_states[i].GetNumTriggers(); ++j) {
|
||||
const u32 triggerCount = in.readUint32Big();
|
||||
const u32 lastTriggerIdx = triggerCount - 1;
|
||||
for (u32 k = 0; k < triggerCount; ++k) {
|
||||
std::string name = in.readString(31, false);
|
||||
bool isNot = name.front() == '!';
|
||||
CAiTriggerFunc func = CAi::GetTrigerFunc(isNot ? name.c_str() + 1 : name.c_str());
|
||||
float arg = in.readFloatBig();
|
||||
const bool isNot = name.front() == '!';
|
||||
const CAiTriggerFunc func = CAi::GetTriggerFunc(isNot ? name.c_str() + 1 : name.c_str());
|
||||
const float arg = in.readFloatBig();
|
||||
CAiTrigger* newTrig;
|
||||
if (k < lastTriggerIdx) {
|
||||
newTrig = &x10_triggers.emplace_back();
|
||||
|
||||
Reference in New Issue
Block a user