diff options
| author | 2019-05-19 02:39:00 -0400 | |
|---|---|---|
| committer | 2019-05-19 02:46:44 -0400 | |
| commit | 683c4e523f55cef1f22263010f2c26ed0e277af1 (patch) | |
| tree | 4d91452c88af708cc993952aad8b924885570aa2 /src | |
| parent | gl_shader_disk_cache: Make variable non-const in decompiled entry case (diff) | |
| download | yuzu-683c4e523f55cef1f22263010f2c26ed0e277af1.tar.gz yuzu-683c4e523f55cef1f22263010f2c26ed0e277af1.tar.xz yuzu-683c4e523f55cef1f22263010f2c26ed0e277af1.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn | |||
| 287 | return {}; | 287 | return {}; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | std::vector<u8> code(code_size); | 290 | std::string code(code_size, '\0'); |
| 291 | if (!LoadArrayFromPrecompiled(code.data(), code.size())) { | 291 | if (!LoadArrayFromPrecompiled(code.data(), code.size())) { |
| 292 | return {}; | 292 | return {}; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | ShaderDiskCacheDecompiled entry; | 295 | ShaderDiskCacheDecompiled entry; |
| 296 | entry.code = std::string(reinterpret_cast<const char*>(code.data()), code_size); | 296 | entry.code = std::move(code); |
| 297 | 297 | ||
| 298 | u32 const_buffers_count{}; | 298 | u32 const_buffers_count{}; |
| 299 | if (!LoadObjectFromPrecompiled(const_buffers_count)) { | 299 | if (!LoadObjectFromPrecompiled(const_buffers_count)) { |