From 683c4e523f55cef1f22263010f2c26ed0e277af1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 19 May 2019 02:39:00 -0400 Subject: gl_shader_disk_cache: Remove redundant code string construction in LoadDecompiledEntry() We don't need to load the code into a vector and then construct a string over the data. We can just create a string with the necessary size ahead of time, and read the data directly into it, getting rid of an unnecessary heap allocation. --- src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/renderer_opengl') diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index 15b9fc6af..4cfb88557 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -287,13 +287,13 @@ std::optional ShaderDiskCacheOpenGL::LoadDecompiledEn return {}; } - std::vector code(code_size); + std::string code(code_size, '\0'); if (!LoadArrayFromPrecompiled(code.data(), code.size())) { return {}; } ShaderDiskCacheDecompiled entry; - entry.code = std::string(reinterpret_cast(code.data()), code_size); + entry.code = std::move(code); u32 const_buffers_count{}; if (!LoadObjectFromPrecompiled(const_buffers_count)) { -- cgit v1.2.3