]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't return references from apply functions
authorMikko Rasa <tdb@tdb.fi>
Mon, 5 Apr 2021 12:22:40 +0000 (15:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 5 Apr 2021 12:26:58 +0000 (15:26 +0300)
It's somewhat error prone, even though it hasn't caused any problems
yet.

source/glsl/debug.cpp
source/glsl/debug.h
source/glsl/optimize.cpp
source/glsl/optimize.h
source/glsl/output.cpp
source/glsl/output.h

index 8bdce457f0d1c318d56dd193c57309f30bdd0646..2f243dc73dc0d25518ce341597749f4255f45d8a 100644 (file)
@@ -8,7 +8,7 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
 namespace GL {
 namespace SL {
 
-const std::string &DumpTree::apply(Stage &stage)
+std::string DumpTree::apply(Stage &stage)
 {
        formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type));
        tree.push_back(BRANCH);
 {
        formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type));
        tree.push_back(BRANCH);
index 73976904aee60d09b5b5c51cb3980e7dac90c692..da888198414f8a7d891a7884a5ddbedd45d7b4cd 100644 (file)
@@ -37,7 +37,7 @@ private:
        std::vector<TreeChars> tree;
 
 public:
        std::vector<TreeChars> tree;
 
 public:
-       const std::string &apply(Stage &);
+       std::string apply(Stage &);
 
 private:
        void append(const std::string &);
 
 private:
        void append(const std::string &);
index 475e8b646de280261b0b1347bf1339a84de578b8..32f7ce67959b388fa1bc2c2fb58ecc344a11bb87 100644 (file)
@@ -123,7 +123,7 @@ InlineContentInjector::InlineContentInjector():
        pass(REFERENCED)
 { }
 
        pass(REFERENCED)
 { }
 
-const string &InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_func, Block &tgt_blk, const NodeList<Statement>::iterator &ins_pt, FunctionCall &call)
+string InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_func, Block &tgt_blk, const NodeList<Statement>::iterator &ins_pt, FunctionCall &call)
 {
        source_func = call.declaration->definition;
 
 {
        source_func = call.declaration->definition;
 
index d434c68a85c1df63594dcda6294c9698573e969f..4113f21465a990e85a4fa701351b8277cec09cfe 100644 (file)
@@ -39,7 +39,7 @@ private:
 public:
        InlineableFunctionLocator();
 
 public:
        InlineableFunctionLocator();
 
-       const std::set<FunctionDeclaration *> &apply(Stage &s) { s.content.visit(*this); return inlineable; }
+       std::set<FunctionDeclaration *> apply(Stage &s) { s.content.visit(*this); return inlineable; }
 
 private:
        virtual void visit(FunctionCall &);
 
 private:
        virtual void visit(FunctionCall &);
@@ -73,7 +73,7 @@ private:
 public:
        InlineContentInjector();
 
 public:
        InlineContentInjector();
 
-       const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList<Statement>::iterator &, FunctionCall &);
+       std::string apply(Stage &, FunctionDeclaration &, Block &, const NodeList<Statement>::iterator &, FunctionCall &);
 
 private:
        virtual void visit(VariableReference &);
 
 private:
        virtual void visit(VariableReference &);
index 38adb5bd6b799f54f165299657b90f09830293de..c15c8c0421b9aae64add279cf11b9c05a03753f6 100644 (file)
@@ -18,7 +18,7 @@ Formatter::Formatter():
        r_empty_name(false)
 { }
 
        r_empty_name(false)
 { }
 
-const string &Formatter::apply(Stage &s)
+string Formatter::apply(Stage &s)
 {
        stage = &s;
        omit_builtin = true;
 {
        stage = &s;
        omit_builtin = true;
index ef9369876b46c00221ad6e33093c6e76153fee93..1e59a445ebdd1f16eead08246ac98196b3a286ca 100644 (file)
@@ -25,8 +25,8 @@ private:
 public:
        Formatter();
 
 public:
        Formatter();
 
-       const std::string &apply(Stage &);
-       const std::string &apply(Node &n) { n.visit(*this); return formatted; }
+       std::string apply(Stage &);
+       std::string apply(Node &n) { n.visit(*this); return formatted; }
 
 private:
        void append(const std::string &);
 
 private:
        void append(const std::string &);