mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
ControllerInterface/Device: Use std::string_view where applicable
In these cases, the given string is only ever compared against other string, so std::string can be turned into a std::string_view to allow non-allocating inputs.
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -42,14 +43,14 @@ public:
|
||||
class Control // input or output
|
||||
{
|
||||
public:
|
||||
virtual ~Control() = default;
|
||||
virtual std::string GetName() const = 0;
|
||||
virtual ~Control() {}
|
||||
virtual Input* ToInput() { return nullptr; }
|
||||
virtual Output* ToOutput() { return nullptr; }
|
||||
|
||||
// May be overridden to allow multiple valid names.
|
||||
// Useful for backwards-compatible configurations when names change.
|
||||
virtual bool IsMatchingName(const std::string& name) const;
|
||||
virtual bool IsMatchingName(std::string_view name) const;
|
||||
};
|
||||
|
||||
//
|
||||
@ -111,8 +112,8 @@ public:
|
||||
const std::vector<Input*>& Inputs() const { return m_inputs; }
|
||||
const std::vector<Output*>& Outputs() const { return m_outputs; }
|
||||
|
||||
Input* FindInput(const std::string& name) const;
|
||||
Output* FindOutput(const std::string& name) const;
|
||||
Input* FindInput(std::string_view name) const;
|
||||
Output* FindOutput(std::string_view name) const;
|
||||
|
||||
protected:
|
||||
void AddInput(Input* const i);
|
||||
@ -124,7 +125,7 @@ protected:
|
||||
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
|
||||
ControlState GetState() const override;
|
||||
std::string GetName() const override;
|
||||
bool IsMatchingName(const std::string& name) const override;
|
||||
bool IsMatchingName(std::string_view name) const override;
|
||||
|
||||
private:
|
||||
Input& m_low;
|
||||
@ -177,8 +178,8 @@ public:
|
||||
class DeviceContainer
|
||||
{
|
||||
public:
|
||||
Device::Input* FindInput(const std::string& name, const Device* def_dev) const;
|
||||
Device::Output* FindOutput(const std::string& name, const Device* def_dev) const;
|
||||
Device::Input* FindInput(std::string_view name, const Device* def_dev) const;
|
||||
Device::Output* FindOutput(std::string_view name, const Device* def_dev) const;
|
||||
|
||||
std::vector<std::string> GetAllDeviceStrings() const;
|
||||
std::string GetDefaultDeviceString() const;
|
||||
|
Reference in New Issue
Block a user