TimingEvent: Use const char* for name instead of string_view

Less memory wasteage.
This commit is contained in:
Stenzek
2026-06-20 13:57:23 +10:00
parent 77fe65995d
commit 15ad0024db
4 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
LOG_CHANNEL(MemoryCard);
static constexpr std::array<std::string_view, NUM_CONTROLLER_AND_CARD_PORTS> s_event_names = {{
static constexpr std::array<const char*, NUM_CONTROLLER_AND_CARD_PORTS> s_event_names = {{
"Memory Card 1 Host Flush",
"Memory Card 2 Host Flush",
"Memory Card 3 Host Flush",
+5 -4
View File
@@ -299,7 +299,7 @@ static TimingEvent* TimingEvents::FindActiveEvent(const std::string_view name)
{
for (TimingEvent* event = s_state.active_events_head; event; event = event->next)
{
if (event->GetName() == name)
if (name == event->GetName())
return event;
}
@@ -512,7 +512,8 @@ bool TimingEvents::DoState(StateWrapper& sw)
for (TimingEvent* event = s_state.active_events_head; event; event = event->next)
{
sw.Do(&event->m_name);
std::string_view event_name = event->GetName();
sw.Do(&event_name);
GlobalTicks next_run_time =
(s_state.current_event == event) ? s_state.current_event_next_run_time : event->m_next_run_time;
sw.Do(&next_run_time);
@@ -528,8 +529,8 @@ bool TimingEvents::DoState(StateWrapper& sw)
return !sw.HasError();
}
TimingEvent::TimingEvent(const std::string_view name, TickCount period, TickCount interval,
TimingEventCallback callback, void* callback_param)
TimingEvent::TimingEvent(const char* name, TickCount period, TickCount interval, TimingEventCallback callback,
void* callback_param)
: m_callback(callback), m_callback_param(callback_param), m_period(period), m_interval(interval), m_name(name)
{
const GlobalTicks ts = TimingEvents::GetTimestampForNewEvent();
+3 -3
View File
@@ -15,11 +15,11 @@ using TimingEventCallback = void (*)(void* param, TickCount ticks);
class TimingEvent
{
public:
TimingEvent(const std::string_view name, TickCount period, TickCount interval, TimingEventCallback callback,
TimingEvent(const char* name, TickCount period, TickCount interval, TimingEventCallback callback,
void* callback_param);
~TimingEvent();
ALWAYS_INLINE const std::string_view GetName() const { return m_name; }
ALWAYS_INLINE const char* GetName() const { return m_name; }
ALWAYS_INLINE bool IsActive() const { return m_active; }
// Returns the number of ticks between each event.
@@ -71,7 +71,7 @@ public:
TickCount m_interval;
bool m_active = false;
std::string_view m_name;
const char* m_name;
};
namespace TimingEvents {
+1 -1
View File
@@ -91,7 +91,7 @@ void StateWrapper::Do(SmallStringBase* value_ptr)
void StateWrapper::Do(std::string_view* value_ptr)
{
Assert(m_mode == Mode::Write);
DebugAssert(m_mode == Mode::Write);
u32 length = static_cast<u32>(value_ptr->length());
Do(&length);
DoBytes(const_cast<char*>(value_ptr->data()), length);