From db5b8b9c88512f86327740a0b609057a3b08cbab Mon Sep 17 00:00:00 2001 From: Marshall Mohror Date: Mon, 20 Apr 2020 22:08:58 -0500 Subject: [PATCH] video_core: reduce string allocations in shader decompiler (#5261) * video_core: reduce string allocations in shader decompiler * use append for indentation instead of resize Co-authored-by: Mat M. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 9e436b0f5c..7adfa3bbab 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -196,12 +196,13 @@ private: class ShaderWriter { public: - void AddLine(const std::string& text) { + void AddLine(std::string_view text) { DEBUG_ASSERT(scope >= 0); if (!text.empty()) { - shader_source += std::string(static_cast(scope) * 4, ' '); + shader_source.append(static_cast(scope) * 4, ' '); } - shader_source += text + '\n'; + shader_source += text; + shader_source += '\n'; } std::string MoveResult() {