yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

glsl_shader_decompiler: Use std::string_view instead of std::string for AddLine()

This function doesn't need to take ownership of the string data being
given to it, considering all we do is append the characters to the
internal string instance.

Instead, use a string view to simply reference the string data without
any potential heap allocation.

Now anything that is a raw const char* won't need to be converted to a
std::string before appending.
This commit is contained in:
Lioncash 2018-04-19 20:10:40 -04:00
parent 412b31ad72
commit e3b6f6c016
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include <string_view>
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "video_core/engines/shader_bytecode.h" #include "video_core/engines/shader_bytecode.h"
@ -109,7 +110,7 @@ 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()) {
AppendIndentation(); AppendIndentation();