settings: devirtualize SettingsInterface
SettingsInterface was a base class with five pure-virtual config-getter
methods, defined in core/settings.h. There has only ever been one
concrete subclass: LibretroSettingsInterface (in libretro/), which
backs every GetXxxValue call with a single retro_environment_callback
to RETRO_ENVIRONMENT_GET_VARIABLE.
The single-impl shape means every si.GetBoolValue / si.GetIntValue /
si.GetStringValue call in Settings::Load and elsewhere goes through a
vtable indirection that resolves to exactly one place. Settings::Load
issues 61 such calls, and runs at boot plus on every libretro
core-options change. The cost per call is small (~2 ns per virtual
dispatch on modern CPUs), so the wall-clock saving is modest, but
the abstraction itself buys nothing - there is no second
implementation, no plan to add one (the core target is libretro-only),
and no use case where the indirection would help.
Drop the base class:
- Remove 'class SettingsInterface' from core/settings.h, along with
its virtual destructor and five pure virtuals.
- Remove the SettingsInterface destructor definition from
core/settings.cpp.
- Make LibretroSettingsInterface a plain class with non-virtual
methods (drop the 'override' keyword and the public-inheritance
base).
- Change Settings::Load's signature from (SettingsInterface&) to
(LibretroSettingsInterface&). The one caller already passes a
LibretroSettingsInterface, so no call site needs to change.
- Forward-declare LibretroSettingsInterface in core/settings.h
(the type only appears as a reference in Load's signature) and
include the libretro header from settings.cpp where the
member function calls actually have to see the definition.
The forward-declaration plus include-from-cpp pattern keeps
core/settings.h free of libretro headers - a header-level layering
nicety. The cpp-level dependency is an existing pattern (multiple
core/ TUs already include libretro/ headers - gpu_hw_d3d11.cpp,
gpu_hw_opengl.cpp, gpu_hw_vulkan.cpp, texture_replacements.cpp).
Linux x64 build still warning-clean. .so size drops from 8048432
to 8047800 bytes (-632) from removing the SettingsInterface vtable,
its typeinfo, the virtual destructor, and the indirect-call sites
in Settings::Load. 25 retro_* exports unchanged. Behaviour is
identical (same calls, same arguments, just direct now).
This commit is contained in:
parent
354b8b5e6d
commit
2fdb5240d4
3 changed files with 13 additions and 23 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "host_display.h"
|
||||
#include "host_interface.h"
|
||||
#include "libretro/libretro_settings_interface.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
|
@ -10,8 +11,6 @@
|
|||
|
||||
Settings g_settings;
|
||||
|
||||
SettingsInterface::~SettingsInterface() = default;
|
||||
|
||||
const char* SettingInfo::StringDefaultValue() const
|
||||
{
|
||||
return default_value ? default_value : "";
|
||||
|
|
@ -132,7 +131,7 @@ void Settings::UpdateOverclockActive()
|
|||
cpu_overclock_active = (cpu_overclock_enable && (cpu_overclock_numerator != 1 || cpu_overclock_denominator != 1));
|
||||
}
|
||||
|
||||
void Settings::Load(SettingsInterface& si)
|
||||
void Settings::Load(LibretroSettingsInterface& si)
|
||||
{
|
||||
region =
|
||||
ParseConsoleRegionName(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue