Misc: Pass string_view by value

This commit is contained in:
Stenzek
2024-05-05 20:21:54 +10:00
parent e4d940a476
commit ca3cfbaa99
111 changed files with 543 additions and 542 deletions

View File

@ -1699,7 +1699,7 @@ void EmuThread::wakeThread()
QMetaObject::invokeMethod(m_event_loop, "quit", Qt::QueuedConnection);
}
void Host::ReportFatalError(const std::string_view& title, const std::string_view& message)
void Host::ReportFatalError(std::string_view title, std::string_view message)
{
auto cb = [title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message)]() {
QMessageBox::critical(g_main_window && g_main_window->isVisible() ? g_main_window : nullptr, title, message);
@ -1727,7 +1727,7 @@ void Host::ReportFatalError(const std::string_view& title, const std::string_vie
}
}
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message)
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
{
if (!title.empty() && !message.empty())
{
@ -1745,7 +1745,7 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie
Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size())));
}
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message)
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
{
auto lock = g_emu_thread->pauseAndLockSystem();
@ -1753,12 +1753,12 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view&
QString::fromUtf8(message.data(), message.size()));
}
void Host::OpenURL(const std::string_view& url)
void Host::OpenURL(std::string_view url)
{
QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); });
}
bool Host::CopyTextToClipboard(const std::string_view& text)
bool Host::CopyTextToClipboard(std::string_view text)
{
QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() {
QClipboard* clipboard = QGuiApplication::clipboard();
@ -1768,7 +1768,7 @@ bool Host::CopyTextToClipboard(const std::string_view& text)
return true;
}
void Host::ReportDebuggerMessage(const std::string_view& message)
void Host::ReportDebuggerMessage(std::string_view message)
{
emit g_emu_thread->debuggerMessageReported(QString::fromUtf8(message));
}
@ -1777,14 +1777,14 @@ void Host::AddFixedInputBindings(SettingsInterface& si)
{
}
void Host::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name)
void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
{
emit g_emu_thread->onInputDeviceConnected(
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()),
device_name.empty() ? QString() : QString::fromUtf8(device_name.data(), device_name.size()));
}
void Host::OnInputDeviceDisconnected(const std::string_view& identifier)
void Host::OnInputDeviceDisconnected(std::string_view identifier)
{
emit g_emu_thread->onInputDeviceDisconnected(
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()));

View File

@ -458,7 +458,7 @@ static constexpr KeyCodeName s_qt_key_names[] = {{Qt::Key_Escape, "Escape", ICON
{Qt::Key_Camera, "Camera", nullptr},
{Qt::Key_CameraFocus, "CameraFocus", nullptr}};
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str)
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(std::string_view str)
{
std::string_view compare_name = str;
u32 modifier_bits = 0;

View File

@ -55,10 +55,10 @@ struct GlyphInfo
};
static QString FixLanguageName(const QString& language);
static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language);
static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, std::string_view language);
static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const char* font_url,
const std::string& path);
static const GlyphInfo* GetGlyphInfo(const std::string_view& language);
static const GlyphInfo* GetGlyphInfo(std::string_view language);
static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf";
#define MAKE_FONT_DOWNLOAD_URL(name) "https://www.duckstation.org/runtime-resources/fonts/" name
@ -156,7 +156,7 @@ QString QtHost::FixLanguageName(const QString& language)
return language;
}
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf,
size_t tbuf_space)
{
// This is really awful. Thankfully we're caching the results...
@ -220,7 +220,7 @@ static constexpr const ImWchar s_central_european_ranges[] = {
0x0100, 0x017F, // Central European diacritics
};
void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language)
void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, std::string_view language)
{
const GlyphInfo* gi = GetGlyphInfo(language);
@ -357,7 +357,7 @@ static constexpr const QtHost::GlyphInfo s_glyph_info[] = {
};
// clang-format on
const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view& language)
const QtHost::GlyphInfo* QtHost::GetGlyphInfo(std::string_view language)
{
for (const GlyphInfo& it : s_glyph_info)
{

View File

@ -205,7 +205,7 @@ std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title,
return address;
}
QString StringViewToQString(const std::string_view& str)
QString StringViewToQString(std::string_view str)
{
return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size());
}

View File

@ -93,7 +93,7 @@ void OpenURL(QWidget* parent, const char* url);
std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code);
/// Converts a std::string_view to a QString safely.
QString StringViewToQString(const std::string_view& str);
QString StringViewToQString(std::string_view str);
/// Sets a widget to italics if the setting value is inherited.
void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited);