From 2e556fe6b6d82c2d4a3ca3fb4bbd402486a8933c Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 2 Aug 2023 13:25:22 -0230 Subject: [PATCH] A cleaner fix for the last commit. --- src/common/PhysicalJoystick.cxx | 4 ++-- src/common/PhysicalJoystick.hxx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index a893b1962..c04d13ee4 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -89,7 +89,7 @@ bool PhysicalJoystick::setMap(const json& map) continue; if(entry.key() == "port") { - port = getPort(entry.value()); + port = getPort(string{entry.value()}); // json doesn't support string_view continue; } @@ -126,7 +126,7 @@ string PhysicalJoystick::getName(const PhysicalJoystick::Port _port) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PhysicalJoystick::Port PhysicalJoystick::getPort(const string& portName) const +PhysicalJoystick::Port PhysicalJoystick::getPort(string_view portName) const { static constexpr std::array(PhysicalJoystick::Port::NUM_PORTS)> NAMES = diff --git a/src/common/PhysicalJoystick.hxx b/src/common/PhysicalJoystick.hxx index 07aef67c8..ee0aaa422 100644 --- a/src/common/PhysicalJoystick.hxx +++ b/src/common/PhysicalJoystick.hxx @@ -90,7 +90,7 @@ class PhysicalJoystick // Convert from string to Port type and vice versa string getName(const Port _port) const; - Port getPort(const string& portName) const; // FIXME: allow string_view + Port getPort(string_view portName) const; friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) { os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes