Skip to content
Permalink
Browse files
Merge pull request #8362 from GerbilSoft/feature/string-optimizations…
….2019-09-11

Various string and other optimizations
  • Loading branch information
delroth committed Dec 30, 2019
2 parents 084344a + 11339d7 commit 7a6a451
Show file tree
Hide file tree
Showing 24 changed files with 217 additions and 182 deletions.
@@ -147,7 +147,7 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int
{
Stop();
file_index++;
std::stringstream filename;
std::ostringstream filename;
filename << File::GetUserPath(D_DUMPAUDIO_IDX) << basename << file_index << ".wav";
Start(filename.str(), sample_rate);
current_sample_rate = sample_rate;
@@ -104,7 +104,7 @@ std::vector<std::string> Watches::SaveToStrings() const
std::vector<std::string> watches;
for (const auto& watch : m_watches)
{
std::stringstream ss;
std::ostringstream ss;
ss << std::hex << watch.address << " " << watch.name;
watches.push_back(ss.str());
}
@@ -2198,7 +2198,7 @@ static void InitExtensionList(GLContext* context)
default:
case 450:
{
std::string gl450exts[] = {
static const char* const gl450exts[] = {
"GL_ARB_ES3_1_compatibility",
"GL_ARB_clip_control",
"GL_ARB_conditional_render_inverted",
@@ -2216,7 +2216,7 @@ static void InitExtensionList(GLContext* context)
}
case 440:
{
std::string gl440exts[] = {
static const char* const gl440exts[] = {
"GL_ARB_buffer_storage",
"GL_ARB_clear_texture",
"GL_ARB_enhanced_layouts",
@@ -2232,7 +2232,7 @@ static void InitExtensionList(GLContext* context)
}
case 430:
{
std::string gl430exts[] = {
static const char* const gl430exts[] = {
"GL_ARB_ES3_compatibility",
"GL_ARB_arrays_of_arrays",
"GL_ARB_clear_buffer_object",
@@ -2260,7 +2260,7 @@ static void InitExtensionList(GLContext* context)
}
case 420:
{
std::string gl420exts[] = {
static const char* const gl420exts[] = {
"GL_ARB_base_instance",
"GL_ARB_compressed_texture_pixel_storage",
"GL_ARB_conservative_depth",
@@ -2280,7 +2280,7 @@ static void InitExtensionList(GLContext* context)
}
case 410:
{
std::string gl410exts[] = {
static const char* const gl410exts[] = {
"GL_ARB_ES2_compatibility",
"GL_ARB_get_program_binary",
"GL_ARB_separate_shader_objects",
@@ -2294,7 +2294,7 @@ static void InitExtensionList(GLContext* context)
}
case 400:
{
std::string gl400exts[] = {
static const char* const gl400exts[] = {
"GL_ARB_draw_indirect",
"GL_ARB_gpu_shader5",
"GL_ARB_gpu_shader_fp64",
@@ -2314,7 +2314,7 @@ static void InitExtensionList(GLContext* context)
}
case 330:
{
std::string gl330exts[] = {
static const char* const gl330exts[] = {
"GL_ARB_shader_bit_encoding",
"GL_ARB_blend_func_extended",
"GL_ARB_explicit_attrib_location",
@@ -2332,7 +2332,7 @@ static void InitExtensionList(GLContext* context)
}
case 320:
{
std::string gl320exts[] = {
static const char* const gl320exts[] = {
"GL_ARB_geometry_shader4",
"GL_ARB_sync",
"GL_ARB_vertex_array_bgra",
@@ -2350,7 +2350,7 @@ static void InitExtensionList(GLContext* context)
case 310:
{
// Can't add NV_primitive_restart since function name changed
std::string gl310exts[] = {
static const char* const gl310exts[] = {
"GL_ARB_draw_instanced",
"GL_ARB_copy_buffer",
"GL_ARB_texture_buffer_object",
@@ -2366,7 +2366,7 @@ static void InitExtensionList(GLContext* context)
{
// Quite a lot of these had their names changed when merged in to core
// Disable the ones that have
std::string gl300exts[] = {
static const char* const gl300exts[] = {
"GL_ARB_map_buffer_range",
"GL_ARB_color_buffer_float",
"GL_ARB_texture_float",
@@ -398,7 +398,7 @@ std::string JoinStrings(const std::vector<std::string>& strings, const std::stri
if (strings.empty())
return "";

std::stringstream res;
std::ostringstream res;
std::copy(strings.begin(), strings.end(),
std::ostream_iterator<std::string>(res, delimiter.c_str()));

@@ -22,134 +22,136 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
if (config_location.system == Config::System::Logger)
return true;

if (config_location.system == Config::System::Main && config_location.section == "NetPlay")
return true;

if (config_location.system == Config::System::Main && config_location.section == "General")
return true;
if (config_location.system == Config::System::Main)
{
if (config_location.section == "NetPlay" || config_location.section == "General")
return true;
}

const static std::vector<Config::ConfigLocation> s_setting_saveable{
static constexpr std::array<const Config::ConfigLocation*, 92> s_setting_saveable = {
// Main.Core

Config::MAIN_DEFAULT_ISO.location,
Config::MAIN_MEMCARD_A_PATH.location,
Config::MAIN_MEMCARD_B_PATH.location,
Config::MAIN_AUTO_DISC_CHANGE.location,
Config::MAIN_DPL2_DECODER.location,
Config::MAIN_DPL2_QUALITY.location,
&Config::MAIN_DEFAULT_ISO.location,
&Config::MAIN_MEMCARD_A_PATH.location,
&Config::MAIN_MEMCARD_B_PATH.location,
&Config::MAIN_AUTO_DISC_CHANGE.location,
&Config::MAIN_DPL2_DECODER.location,
&Config::MAIN_DPL2_QUALITY.location,

// Main.Display
Config::MAIN_FULLSCREEN_DISPLAY_RES.location,
Config::MAIN_FULLSCREEN.location,
Config::MAIN_RENDER_TO_MAIN.location,
Config::MAIN_RENDER_WINDOW_AUTOSIZE.location,
Config::MAIN_KEEP_WINDOW_ON_TOP.location,
Config::MAIN_DISABLE_SCREENSAVER.location,
&Config::MAIN_FULLSCREEN_DISPLAY_RES.location,
&Config::MAIN_FULLSCREEN.location,
&Config::MAIN_RENDER_TO_MAIN.location,
&Config::MAIN_RENDER_WINDOW_AUTOSIZE.location,
&Config::MAIN_KEEP_WINDOW_ON_TOP.location,
&Config::MAIN_DISABLE_SCREENSAVER.location,

// Graphics.Hardware

Config::GFX_VSYNC.location,
Config::GFX_ADAPTER.location,
&Config::GFX_VSYNC.location,
&Config::GFX_ADAPTER.location,

// Graphics.Settings

Config::GFX_WIDESCREEN_HACK.location,
Config::GFX_ASPECT_RATIO.location,
Config::GFX_CROP.location,
Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
Config::GFX_SHOW_FPS.location,
Config::GFX_SHOW_NETPLAY_PING.location,
Config::GFX_SHOW_NETPLAY_MESSAGES.location,
Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
Config::GFX_OVERLAY_STATS.location,
Config::GFX_OVERLAY_PROJ_STATS.location,
Config::GFX_DUMP_TEXTURES.location,
Config::GFX_HIRES_TEXTURES.location,
Config::GFX_CACHE_HIRES_TEXTURES.location,
Config::GFX_DUMP_EFB_TARGET.location,
Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
Config::GFX_FREE_LOOK.location,
Config::GFX_USE_FFV1.location,
Config::GFX_DUMP_FORMAT.location,
Config::GFX_DUMP_CODEC.location,
Config::GFX_DUMP_ENCODER.location,
Config::GFX_DUMP_PATH.location,
Config::GFX_BITRATE_KBPS.location,
Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location,
Config::GFX_ENABLE_PIXEL_LIGHTING.location,
Config::GFX_FAST_DEPTH_CALC.location,
Config::GFX_MSAA.location,
Config::GFX_SSAA.location,
Config::GFX_EFB_SCALE.location,
Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
Config::GFX_TEXFMT_OVERLAY_CENTER.location,
Config::GFX_ENABLE_WIREFRAME.location,
Config::GFX_DISABLE_FOG.location,
Config::GFX_BORDERLESS_FULLSCREEN.location,
Config::GFX_ENABLE_VALIDATION_LAYER.location,
Config::GFX_BACKEND_MULTITHREADING.location,
Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location,
Config::GFX_SHADER_CACHE.location,
Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING.location,
Config::GFX_SHADER_COMPILATION_MODE.location,
Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_SHADER_PRECOMPILER_THREADS.location,
Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE.location,

Config::GFX_SW_ZCOMPLOC.location,
Config::GFX_SW_ZFREEZE.location,
Config::GFX_SW_DUMP_OBJECTS.location,
Config::GFX_SW_DUMP_TEV_STAGES.location,
Config::GFX_SW_DUMP_TEV_TEX_FETCHES.location,
Config::GFX_SW_DRAW_START.location,
Config::GFX_SW_DRAW_END.location,
&Config::GFX_WIDESCREEN_HACK.location,
&Config::GFX_ASPECT_RATIO.location,
&Config::GFX_CROP.location,
&Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
&Config::GFX_SHOW_FPS.location,
&Config::GFX_SHOW_NETPLAY_PING.location,
&Config::GFX_SHOW_NETPLAY_MESSAGES.location,
&Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
&Config::GFX_OVERLAY_STATS.location,
&Config::GFX_OVERLAY_PROJ_STATS.location,
&Config::GFX_DUMP_TEXTURES.location,
&Config::GFX_HIRES_TEXTURES.location,
&Config::GFX_CACHE_HIRES_TEXTURES.location,
&Config::GFX_DUMP_EFB_TARGET.location,
&Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
&Config::GFX_FREE_LOOK.location,
&Config::GFX_USE_FFV1.location,
&Config::GFX_DUMP_FORMAT.location,
&Config::GFX_DUMP_CODEC.location,
&Config::GFX_DUMP_ENCODER.location,
&Config::GFX_DUMP_PATH.location,
&Config::GFX_BITRATE_KBPS.location,
&Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
&Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location,
&Config::GFX_ENABLE_PIXEL_LIGHTING.location,
&Config::GFX_FAST_DEPTH_CALC.location,
&Config::GFX_MSAA.location,
&Config::GFX_SSAA.location,
&Config::GFX_EFB_SCALE.location,
&Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
&Config::GFX_TEXFMT_OVERLAY_CENTER.location,
&Config::GFX_ENABLE_WIREFRAME.location,
&Config::GFX_DISABLE_FOG.location,
&Config::GFX_BORDERLESS_FULLSCREEN.location,
&Config::GFX_ENABLE_VALIDATION_LAYER.location,
&Config::GFX_BACKEND_MULTITHREADING.location,
&Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location,
&Config::GFX_SHADER_CACHE.location,
&Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING.location,
&Config::GFX_SHADER_COMPILATION_MODE.location,
&Config::GFX_SHADER_COMPILER_THREADS.location,
&Config::GFX_SHADER_PRECOMPILER_THREADS.location,
&Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE.location,

&Config::GFX_SW_ZCOMPLOC.location,
&Config::GFX_SW_ZFREEZE.location,
&Config::GFX_SW_DUMP_OBJECTS.location,
&Config::GFX_SW_DUMP_TEV_STAGES.location,
&Config::GFX_SW_DUMP_TEV_TEX_FETCHES.location,
&Config::GFX_SW_DRAW_START.location,
&Config::GFX_SW_DRAW_END.location,

// Graphics.Enhancements

Config::GFX_ENHANCE_FORCE_FILTERING.location,
Config::GFX_ENHANCE_MAX_ANISOTROPY.location,
Config::GFX_ENHANCE_POST_SHADER.location,
Config::GFX_ENHANCE_FORCE_TRUE_COLOR.location,
Config::GFX_ENHANCE_DISABLE_COPY_FILTER.location,
Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION.location,
&Config::GFX_ENHANCE_FORCE_FILTERING.location,
&Config::GFX_ENHANCE_MAX_ANISOTROPY.location,
&Config::GFX_ENHANCE_POST_SHADER.location,
&Config::GFX_ENHANCE_FORCE_TRUE_COLOR.location,
&Config::GFX_ENHANCE_DISABLE_COPY_FILTER.location,
&Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION.location,

// Graphics.Stereoscopy

Config::GFX_STEREO_MODE.location,
Config::GFX_STEREO_DEPTH.location,
Config::GFX_STEREO_CONVERGENCE_PERCENTAGE.location,
Config::GFX_STEREO_SWAP_EYES.location,
Config::GFX_STEREO_CONVERGENCE.location,
Config::GFX_STEREO_EFB_MONO_DEPTH.location,
Config::GFX_STEREO_DEPTH_PERCENTAGE.location,
&Config::GFX_STEREO_MODE.location,
&Config::GFX_STEREO_DEPTH.location,
&Config::GFX_STEREO_CONVERGENCE_PERCENTAGE.location,
&Config::GFX_STEREO_SWAP_EYES.location,
&Config::GFX_STEREO_CONVERGENCE.location,
&Config::GFX_STEREO_EFB_MONO_DEPTH.location,
&Config::GFX_STEREO_DEPTH_PERCENTAGE.location,

// Graphics.Hacks

Config::GFX_HACK_EFB_ACCESS_ENABLE.location,
Config::GFX_HACK_EFB_DEFER_INVALIDATION.location,
Config::GFX_HACK_EFB_ACCESS_TILE_SIZE.location,
Config::GFX_HACK_BBOX_ENABLE.location,
Config::GFX_HACK_FORCE_PROGRESSIVE.location,
Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location,
Config::GFX_HACK_DISABLE_COPY_TO_VRAM.location,
Config::GFX_HACK_DEFER_EFB_COPIES.location,
Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_COPY_EFB_SCALED.location,
Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location,
Config::GFX_HACK_VERTEX_ROUDING.location,
&Config::GFX_HACK_EFB_ACCESS_ENABLE.location,
&Config::GFX_HACK_EFB_DEFER_INVALIDATION.location,
&Config::GFX_HACK_EFB_ACCESS_TILE_SIZE.location,
&Config::GFX_HACK_BBOX_ENABLE.location,
&Config::GFX_HACK_FORCE_PROGRESSIVE.location,
&Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
&Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location,
&Config::GFX_HACK_DISABLE_COPY_TO_VRAM.location,
&Config::GFX_HACK_DEFER_EFB_COPIES.location,
&Config::GFX_HACK_IMMEDIATE_XFB.location,
&Config::GFX_HACK_COPY_EFB_SCALED.location,
&Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location,
&Config::GFX_HACK_VERTEX_ROUDING.location,

// Graphics.GameSpecific

Config::GFX_PERF_QUERIES_ENABLE.location,
&Config::GFX_PERF_QUERIES_ENABLE.location,

// UI.General

Config::MAIN_USE_DISCORD_PRESENCE.location,
&Config::MAIN_USE_DISCORD_PRESENCE.location,
};

return std::find(s_setting_saveable.begin(), s_setting_saveable.end(), config_location) !=
s_setting_saveable.end();
return std::any_of(s_setting_saveable.cbegin(), s_setting_saveable.cend(),
[&config_location](const Config::ConfigLocation* location) {
return *location == config_location;
});
}
} // namespace ConfigLoaders
@@ -307,7 +307,7 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
s_com_csr.CHANNEL, request_length, expected_response_length, actual_response_length);
if (expected_response_length != actual_response_length)
{
std::stringstream ss;
std::ostringstream ss;
for (u8 b : request_copy)
{
ss << std::hex << std::setw(2) << std::setfill('0') << (int)b << ' ';
@@ -512,7 +512,7 @@ void BluetoothReal::LoadLinkKeys()
for (size_t i = 0; i < key_string.length(); i = i + 2)
{
int value;
std::stringstream(key_string.substr(i, 2)) >> std::hex >> value;
std::istringstream(key_string.substr(i, 2)) >> std::hex >> value;
key[pos++] = value;
}

@@ -18,7 +18,7 @@ namespace IOS::HLE::Device
{
static void GetVidPidFromDevicePath(const std::string& device_path, u16& vid, u16& pid)
{
std::stringstream stream{device_path};
std::istringstream stream{device_path};
std::string segment;
std::vector<std::string> list;
while (std::getline(stream, segment, '/'))
@@ -50,7 +50,7 @@ void MemoryWatcher::ParseLine(const std::string& line)
m_values[line] = 0;
m_addresses[line] = std::vector<u32>();

std::stringstream offsets(line);
std::istringstream offsets(line);
offsets >> std::hex;
u32 offset;
while (offsets >> offset)
@@ -76,7 +76,7 @@ u32 MemoryWatcher::ChasePointer(const std::string& line)

std::string MemoryWatcher::ComposeMessages()
{
std::stringstream message_stream;
std::ostringstream message_stream;
message_stream << std::hex;

for (auto& entry : m_values)

0 comments on commit 7a6a451

Please sign in to comment.