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. <mathew1800@gmail.com>
This commit is contained in:
Marshall Mohror 2020-04-20 22:08:58 -05:00 committed by GitHub
parent b82d4315fe
commit db5b8b9c88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,12 +196,13 @@ private:
class ShaderWriter { class ShaderWriter {
public: public:
void AddLine(const std::string& text) { void AddLine(std::string_view text) {
DEBUG_ASSERT(scope >= 0); DEBUG_ASSERT(scope >= 0);
if (!text.empty()) { if (!text.empty()) {
shader_source += std::string(static_cast<std::size_t>(scope) * 4, ' '); shader_source.append(static_cast<std::size_t>(scope) * 4, ' ');
} }
shader_source += text + '\n'; shader_source += text;
shader_source += '\n';
} }
std::string MoveResult() { std::string MoveResult() {