mirror of
https://github.com/stenzek/duckstation.git
synced 2026-07-11 01:24:11 +02:00
TimingEvent: Use const char* for name instead of string_view
Less memory wasteage.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user