aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorLioncash <[email protected]>2019-03-14 02:52:54 -0400
committerReinUsesLisp <[email protected]>2019-03-14 04:30:39 -0300
commit6fd44e494c774cab65db05f0dca3a363b8180094 (patch)
treed2e663e8475b6b8bb98167279267460b560b7da9 /include
parentd5c37d242a594b86aa77c8bebff901959db8d0d8 (diff)
downloadsirit-6fd44e494c774cab65db05f0dca3a363b8180094.tar.gz
sirit-6fd44e494c774cab65db05f0dca3a363b8180094.zip
Pass std::string by value where applicable.
By taking the std::string by value in the constructor, this allows for certain situations where copies can be elided entirely (when moving an instance into the constructor) e.g. std::string var = ... ... ... = LiteralString(std::move(var)) // Or whatever other initialization // is done. No copy will be done in this case, the move transfers it into the constructor, and then the move within the initializer list transfers it into the member variable. tl;dr: This allows the calling code to potentially construct less std::string instances by allowing moving into the parameters themselves.
Diffstat (limited to 'include')
-rw-r--r--include/sirit/sirit.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h
index 97383e1..0a1af97 100644
--- a/include/sirit/sirit.h
+++ b/include/sirit/sirit.h
@@ -40,7 +40,7 @@ public:
std::vector<std::uint8_t> Assemble() const;
/// Adds a SPIR-V extension.
- void AddExtension(const std::string& extension_name);
+ void AddExtension(std::string extension_name);
/// Adds a module capability.
void AddCapability(spv::Capability capability);
@@ -49,14 +49,14 @@ public:
void SetMemoryModel(spv::AddressingModel addressing_model, spv::MemoryModel memory_model);
/// Adds an entry point.
- void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, const std::string& name,
+ void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, std::string name,
const std::vector<Id>& interfaces = {});
/// Adds an entry point.
template <typename... Ts>
- void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, const std::string& name,
+ void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, std::string name,
Ts&&... interfaces) {
- AddEntryPoint(execution_model, entry_point, name, {interfaces...});
+ AddEntryPoint(execution_model, std::move(entry_point), name, {interfaces...});
}
/// Declare an execution mode for an entry point.
@@ -131,7 +131,7 @@ public:
}
/// Returns type opaque.
- Id TypeOpaque(const std::string& name);
+ Id TypeOpaque(std::string name);
/// Returns type pointer.
Id TypePointer(spv::StorageClass storage_class, Id type);
@@ -224,8 +224,8 @@ public:
Id OpLabel();
/// The block label instruction: Any reference to a block is through this ref.
- Id OpLabel(const std::string& label_name) {
- return Name(OpLabel(), label_name);
+ Id OpLabel(std::string label_name) {
+ return Name(OpLabel(), std::move(label_name));
}
/// Unconditional jump to label.
@@ -253,14 +253,14 @@ public:
/// Assign a name string to a reference.
/// @return target
- Id Name(Id target, const std::string& name);
+ Id Name(Id target, std::string name);
/// Assign a name string to a member of a structure type.
/// @return type
- Id MemberName(Id type, std::uint32_t member, const std::string& name);
+ Id MemberName(Id type, std::uint32_t member, std::string name);
/// Assign a Result <id> to a string for use by other debug instructions.
- Id String(const std::string& string);
+ Id String(std::string string);
/// Add source-level location information
Id OpLine(Id file, Literal line, Literal column);