[Bf-blender-cvs] [13e06e76706] functions: use string ref in more places

Jacques Lucke noreply at git.blender.org
Wed May 15 11:43:14 CEST 2019


Commit: 13e06e76706fe9872a494b655b2d4c9d759dc983
Author: Jacques Lucke
Date:   Wed May 15 11:22:50 2019 +0200
Branches: functions
https://developer.blender.org/rB13e06e76706fe9872a494b655b2d4c9d759dc983

use string ref in more places

===================================================================

M	source/blender/functions/backends/llvm/ir_to_tuple_call.cpp
M	source/blender/functions/backends/tuple_call/tuple_call.hpp
M	source/blender/functions/core/data_flow_graph.hpp
M	source/blender/functions/core/function.hpp
M	source/blender/functions/functions/auto_vectorization.cpp

===================================================================

diff --git a/source/blender/functions/backends/llvm/ir_to_tuple_call.cpp b/source/blender/functions/backends/llvm/ir_to_tuple_call.cpp
index 8f38360fe26..8c2b3657b6b 100644
--- a/source/blender/functions/backends/llvm/ir_to_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/ir_to_tuple_call.cpp
@@ -46,7 +46,7 @@ static llvm::Function *insert_tuple_call_function(SharedFunction &fn, llvm::Modu
       void_ty, to_llvm_array_ref(input_types), false);
 
   llvm::Function *function = llvm::Function::Create(
-      function_type, llvm::GlobalValue::LinkageTypes::ExternalLinkage, fn->name(), module);
+      function_type, llvm::GlobalValue::LinkageTypes::ExternalLinkage, fn->name().data(), module);
 
   llvm::BasicBlock *bb = llvm::BasicBlock::Create(context, "entry", function);
   CodeBuilder builder(bb);
@@ -123,7 +123,7 @@ class LLVMTupleCall : public TupleCallBody {
 static std::unique_ptr<CompiledLLVM> compile_ir_to_tuple_call(SharedFunction &fn,
                                                               llvm::LLVMContext &context)
 {
-  llvm::Module *module = new llvm::Module(fn->name(), context);
+  llvm::Module *module = new llvm::Module(fn->name().data(), context);
   llvm::Function *function = insert_tuple_call_function(fn, module);
 
   auto compiled = CompiledLLVM::FromIR(module, function);
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index 50c43cf7501..9ce96542449 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -35,7 +35,7 @@ class TupleCallBody : public TupleCallBodyBase {
 
   inline void call__setup_stack(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx) const
   {
-    TextStackFrame frame(this->owner()->name().c_str());
+    TextStackFrame frame(this->owner()->name().data());
     ctx.stack().push(&frame);
     this->call(fn_in, fn_out, ctx);
     ctx.stack().pop();
@@ -135,7 +135,7 @@ class LazyInTupleCallBody : public TupleCallBodyBase {
                                 ExecutionContext &ctx,
                                 LazyState &state) const
   {
-    TextStackFrame frame(this->owner()->name().c_str());
+    TextStackFrame frame(this->owner()->name().data());
     ctx.stack().push(&frame);
     this->call(fn_in, fn_out, ctx, state);
     ctx.stack().pop();
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index cc0f9e07d38..752b278e409 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -236,7 +236,7 @@ class DataFlowGraph : public RefCountedBase {
 
   const char *name_ptr_of_node(uint node_id) const
   {
-    return m_nodes[node_id].function->name().c_str();
+    return m_nodes[node_id].function->name().data();
   }
 
   uint origin_of_input(uint input_id) const
diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index 59a1cb57729..5bd625d2fee 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -38,8 +38,8 @@ class Function final : public RefCountedBase {
  public:
   Function(Function &fn) = delete;
 
-  Function(const std::string &name, const Signature &signature)
-      : m_name(name), m_signature(signature)
+  Function(StringRef name, const Signature &signature)
+      : m_name(name.to_std_string()), m_signature(signature)
   {
   }
 
@@ -49,7 +49,7 @@ class Function final : public RefCountedBase {
 
   ~Function() = default;
 
-  const std::string &name() const
+  const StringRefNull name() const
   {
     return m_name;
   }
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index 61977a1ae27..89e2f4b3ba7 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -296,7 +296,7 @@ class AutoVectorization : public TupleCallBody {
     FN_TUPLE_CALL_ALLOC_TUPLES(m_main_body, main_in, main_out);
 
     IterationStackFrame iteration_frame;
-    TextStackFrame function_name_frame(m_main->name().c_str());
+    TextStackFrame function_name_frame(m_main->name().data());
     ctx.stack().push(&iteration_frame);
     ctx.stack().push(&function_name_frame);



More information about the Bf-blender-cvs mailing list