FullscreenUI: Avoid per-frame memory allocations with SmallString

This commit is contained in:
Stenzek
2024-04-07 20:43:13 +10:00
parent 631fca3042
commit de1a1af908
6 changed files with 102 additions and 130 deletions

View File

@ -370,12 +370,12 @@ std::string InputManager::ConvertInputBindingKeysToString(InputBindingInfo::Type
return ss.str();
}
bool InputManager::PrettifyInputBinding(std::string& binding)
bool InputManager::PrettifyInputBinding(SmallStringBase& binding)
{
if (binding.empty())
return false;
const std::string_view binding_view(binding);
const std::string_view binding_view = binding.view();
SmallString ret;
bool changed = false;
@ -408,7 +408,7 @@ bool InputManager::PrettifyInputBinding(std::string& binding)
}
if (changed)
binding = ret.view();
binding = ret;
return changed;
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@ -16,6 +16,8 @@
#include "core/input_types.h"
#include "window_info.h"
class SmallStringBase;
/// Class, or source of an input event.
enum class InputSourceType : u32
{
@ -234,7 +236,7 @@ std::string ConvertInputBindingKeysToString(InputBindingInfo::Type binding_type,
size_t num_keys);
/// Represents a binding with icon fonts, if available.
bool PrettifyInputBinding(std::string& binding);
bool PrettifyInputBinding(SmallStringBase& binding);
/// Returns a list of all hotkeys.
std::vector<const HotkeyInfo*> GetHotkeyList();