Quellcode durchsuchen

Replaced most const string & parameters with const string_view & parameters to avoid extra allocations (#145)

Jorrit Rouwe vor 3 Jahren
Ursprung
Commit
b4bd177f35

+ 1 - 1
Jolt/AABBTree/AABBTreeToBuffer.h

@@ -69,7 +69,7 @@ public:
 	static const int TriangleHeaderSize = TriangleCodec::TriangleHeaderSize;
 
 	/// Convert AABB tree. Returns false if failed.
-	bool							Convert(const VertexList &inVertices, const AABBTreeBuilder::Node *inRoot, AABBTreeToBufferStats &outStats, string &outError, EAABBTreeToBufferConvertMode inConvertMode = EAABBTreeToBufferConvertMode::DepthFirst)
+	bool							Convert(const VertexList &inVertices, const AABBTreeBuilder::Node *inRoot, AABBTreeToBufferStats &outStats, const char *&outError, EAABBTreeToBufferConvertMode inConvertMode = EAABBTreeToBufferConvertMode::DepthFirst)
 	{
 		const typename NodeCodec::EncodingContext node_ctx;
 		typename TriangleCodec::EncodingContext tri_ctx;

+ 3 - 3
Jolt/AABBTree/NodeCodec/NodeCodecQuadTreeHalfFloat.h

@@ -71,7 +71,7 @@ public:
 		/// Algorithm can enlarge the bounding boxes of the children during compression and returns these in outChildBoundsMin, outChildBoundsMax
 		/// inNodeBoundsMin, inNodeBoundsMax is the bounding box if inNode possibly widened by compressing the parent node
 		/// Returns uint(-1) on error and reports the error in outError
-		uint							NodeAllocate(const AABBTreeBuilder::Node *inNode, Vec3Arg inNodeBoundsMin, Vec3Arg inNodeBoundsMax, vector<const AABBTreeBuilder::Node *> &ioChildren, Vec3 outChildBoundsMin[NumChildrenPerNode], Vec3 outChildBoundsMax[NumChildrenPerNode], ByteBuffer &ioBuffer, string &outError) const
+		uint							NodeAllocate(const AABBTreeBuilder::Node *inNode, Vec3Arg inNodeBoundsMin, Vec3Arg inNodeBoundsMax, vector<const AABBTreeBuilder::Node *> &ioChildren, Vec3 outChildBoundsMin[NumChildrenPerNode], Vec3 outChildBoundsMax[NumChildrenPerNode], ByteBuffer &ioBuffer, const char *&outError) const
 		{
 			// We don't emit nodes for leafs
 			if (!inNode->HasChildren())
@@ -132,7 +132,7 @@ public:
 		}
 
 		/// Once all nodes have been added, this call finalizes all nodes by patching in the offsets of the child nodes (that were added after the node itself was added)
-		bool						NodeFinalize(const AABBTreeBuilder::Node *inNode, uint inNodeStart, uint inNumChildren, const uint *inChildrenNodeStart, const uint *inChildrenTrianglesStart, ByteBuffer &ioBuffer, string &outError) const
+		bool						NodeFinalize(const AABBTreeBuilder::Node *inNode, uint inNodeStart, uint inNumChildren, const uint *inChildrenNodeStart, const uint *inChildrenTrianglesStart, ByteBuffer &ioBuffer, const char *&outError) const
 		{
 			if (!inNode->HasChildren())
 				return true;
@@ -162,7 +162,7 @@ public:
 		}
 
 		/// Once all nodes have been finalized, this will finalize the header of the nodes
-		bool						Finalize(Header *outHeader, const AABBTreeBuilder::Node *inRoot, uint inRootNodeStart, uint inRootTrianglesStart, string &outError) const
+		bool						Finalize(Header *outHeader, const AABBTreeBuilder::Node *inRoot, uint inRootNodeStart, uint inRootTrianglesStart, const char *&outError) const
 		{
 			uint offset = inRoot->HasChildren()? inRootNodeStart : inRootTrianglesStart;
 			if (offset & OFFSET_NON_SIGNIFICANT_MASK)

+ 2 - 2
Jolt/AABBTree/TriangleCodec/TriangleCodecIndexed8BitPackSOA4Flags.h

@@ -104,7 +104,7 @@ public:
 
 		/// Pack the triangles in inContainer to ioBuffer. This stores the mMaterialIndex of a triangle in the 8 bit flags.
 		/// Returns uint(-1) on error.
-		uint						Pack(const VertexList &inVertices, const IndexedTriangleList &inTriangles, ByteBuffer &ioBuffer, string &outError)
+		uint						Pack(const VertexList &inVertices, const IndexedTriangleList &inTriangles, ByteBuffer &ioBuffer, const char *&outError)
 		{
 			// Determine position of triangles start
 			uint offset = (uint)ioBuffer.size();
@@ -158,7 +158,7 @@ public:
 							outError = "TriangleCodecIndexed8BitPackSOA4Flags: Offset doesn't fit in 8 bit";
 							return uint(-1);
 						}
-						block->mIndices[vertex_nr][block_tri_idx] = (uint8)vertex_offset;											   						
+						block->mIndices[vertex_nr][block_tri_idx] = (uint8)vertex_offset;
 
 						// Store flags
 						uint32 flags = triangle_available? inTriangles[t + block_tri_idx].mMaterialIndex : 0;

+ 9 - 9
Jolt/Core/Profiler.cpp

@@ -38,7 +38,7 @@ void Profiler::NextFrame()
 		t->mCurrentSample = 0;
 }
 
-void Profiler::Dump(string inTag)
+void Profiler::Dump(const string_view &inTag)
 {
 	mDump = true;
 	mDumpTag = inTag;
@@ -161,25 +161,25 @@ void Profiler::DumpInternal()
 			sAggregate(0, Color::sGetDistinctColor(0).GetUInt32(), s, end, aggregators, key_to_aggregators);
 
 	// Dump as list
-	DumpList(tag, aggregators);
+	DumpList(tag.c_str(), aggregators);
 
 	// Dump as chart
-	DumpChart(tag, threads, key_to_aggregators, aggregators);
+	DumpChart(tag.c_str(), threads, key_to_aggregators, aggregators);
 }
 
-static string sHTMLEncode(string inString)
+static string sHTMLEncode(const char *inString)
 {
-	string str = inString;
+	string str(inString);
 	StringReplace(str, "<", "&lt;");
 	StringReplace(str, ">", "&gt;");
 	return str;
 }
 
-void Profiler::DumpList(string inTag, const Aggregators &inAggregators)
+void Profiler::DumpList(const char *inTag, const Aggregators &inAggregators)
 {
 	// Open file
 	ofstream f;
-	f.open(StringFormat("profile_list_%s.html", inTag.c_str()).c_str(), ofstream::out | ofstream::trunc);
+	f.open(StringFormat("profile_list_%s.html", inTag).c_str(), ofstream::out | ofstream::trunc);
 	if (!f.is_open()) 
 		return;
 
@@ -255,11 +255,11 @@ void Profiler::DumpList(string inTag, const Aggregators &inAggregators)
 	f << R"(</tbody></table></body></html>)";
 }
 
-void Profiler::DumpChart(string inTag, const Threads &inThreads, const KeyToAggregator &inKeyToAggregators, const Aggregators &inAggregators)
+void Profiler::DumpChart(const char *inTag, const Threads &inThreads, const KeyToAggregator &inKeyToAggregators, const Aggregators &inAggregators)
 {
 	// Open file
 	ofstream f;
-	f.open(StringFormat("profile_chart_%s.html", inTag.c_str()).c_str(), ofstream::out | ofstream::trunc);
+	f.open(StringFormat("profile_chart_%s.html", inTag).c_str(), ofstream::out | ofstream::trunc);
 	if (!f.is_open()) 
 		return;
 

+ 4 - 4
Jolt/Core/Profiler.h

@@ -81,7 +81,7 @@ public:
 
 	/// Dump profiling statistics at the start of the next frame
 	/// @param inTag If not empty, this overrides the auto incrementing number in the filename of the dump file
-	void						Dump(string inTag = string());
+	void						Dump(const string_view &inTag = string_view());
 
 	/// Add a thread to be instrumented
 	void						AddThread(ProfileThread *inThread);
@@ -144,8 +144,8 @@ private:
 
 	/// Dump profiling statistics
 	void						DumpInternal();
-	void						DumpList(string inTag, const Aggregators &inAggregators);
-	void						DumpChart(string inTag, const Threads &inThreads, const KeyToAggregator &inKeyToAggregators, const Aggregators &inAggregators);
+	void						DumpList(const char *inTag, const Aggregators &inAggregators);
+	void						DumpChart(const char *inTag, const Threads &inThreads, const KeyToAggregator &inKeyToAggregators, const Aggregators &inAggregators);
 
 	mutex						mLock;																///< Lock that protects mThreads
 	vector<ProfileThread *>		mThreads;															///< List of all active threads
@@ -170,7 +170,7 @@ class ProfileThread : public NonCopyable
 {
 public:
 	/// Constructor
-	inline						ProfileThread(const string &inThreadName);
+	inline						ProfileThread(const string_view &inThreadName);
 	inline						~ProfileThread();
 
 	static const uint cMaxSamples = 65536;

+ 1 - 1
Jolt/Core/Profiler.inl

@@ -7,7 +7,7 @@ JPH_NAMESPACE_BEGIN
 // ProfileThread
 //////////////////////////////////////////////////////////////////////////////////////////
 
-ProfileThread::ProfileThread(const string &inThreadName) :
+ProfileThread::ProfileThread(const string_view &inThreadName) :
 	mThreadName(inThreadName)
 {
 	Profiler::sInstance.AddThread(this);

+ 1 - 1
Jolt/Core/Result.h

@@ -149,7 +149,7 @@ public:
 
 	/// Set an error value
 	void				SetError(const char *inError)				{ Clear(); new (&mError) string(inError); mState = EState::Error; }
-	void				SetError(const string &inError)				{ Clear(); new (&mError) string(inError); mState = EState::Error; }
+	void				SetError(const string_view &inError)		{ Clear(); new (&mError) string(inError); mState = EState::Error; }
 	void				SetError(string &&inError)					{ Clear(); new (&mError) string(move(inError)); mState = EState::Error; }
 
 private:

+ 1 - 1
Jolt/Core/StringTools.cpp

@@ -38,7 +38,7 @@ void StringReplace(string &ioString, const string_view &inSearch, const string_v
 	}
 }
 
-void StringToVector(const string &inString, vector<string> &outVector, const string_view &inDelimiter, bool inClearVector)
+void StringToVector(const string_view &inString, vector<string> &outVector, const string_view &inDelimiter, bool inClearVector)
 {
 	JPH_ASSERT(inDelimiter.size() > 0);
 

+ 1 - 1
Jolt/Core/StringTools.h

@@ -35,7 +35,7 @@ constexpr uint64 HashString(const char *inString)
 void StringReplace(string &ioString, const string_view &inSearch, const string_view &inReplace);
 
 /// Convert a delimited string to an array of strings
-void StringToVector(const string &inString, vector<string> &outVector, const string_view &inDelimiter = ",", bool inClearVector = true);
+void StringToVector(const string_view &inString, vector<string> &outVector, const string_view &inDelimiter = ",", bool inClearVector = true);
 
 /// Convert an array strings to a delimited string
 void VectorToString(const vector<string> &inVector, string &outString, const string_view &inDelimiter = ",");

+ 1 - 1
Jolt/Geometry/ConvexHullBuilder.cpp

@@ -243,7 +243,7 @@ bool ConvexHullBuilder::ContainsFace(const vector<int> &inIndices) const
 	return false;
 }
 
-ConvexHullBuilder::EResult ConvexHullBuilder::Initialize(int inMaxVertices, float inTolerance, string &outError)
+ConvexHullBuilder::EResult ConvexHullBuilder::Initialize(int inMaxVertices, float inTolerance, const char *&outError)
 {
 	// Free the faces possibly left over from an earlier hull
 	FreeFaces();

+ 1 - 1
Jolt/Geometry/ConvexHullBuilder.h

@@ -102,7 +102,7 @@ public:
 	/// @param inTolerance Max distance that a point is allowed to be outside of the hull
 	/// @param outError Error message when building fails
 	/// @return Status code that reports if the hull was created or not
-	EResult				Initialize(int inMaxVertices, float inTolerance, string &outError);
+	EResult				Initialize(int inMaxVertices, float inTolerance, const char *&outError);
 
 	/// Returns the amount of vertices that are currently used by the hull
 	int					GetNumVerticesUsed() const;

+ 1 - 1
Jolt/ObjectStream/ObjectStreamTextOut.cpp

@@ -177,7 +177,7 @@ void ObjectStreamTextOut::WriteChar(char inChar)
 	mStream.put(inChar);
 }
 
-void ObjectStreamTextOut::WriteWord(const string &inWord)
+void ObjectStreamTextOut::WriteWord(const string_view &inWord)
 {
 	mStream << inWord;
 }

+ 1 - 1
Jolt/ObjectStream/ObjectStreamTextOut.h

@@ -41,7 +41,7 @@ public:
 
 private:
 	void						WriteChar(char inChar);
-	void						WriteWord(const string &inWord);
+	void						WriteWord(const string_view &inWord);
 
 	int							mIndentation = 0;
 };

+ 1 - 1
Jolt/Physics/Collision/PhysicsMaterialSimple.h

@@ -15,7 +15,7 @@ public:
 
 	/// Constructor
 											PhysicsMaterialSimple() = default;
-											PhysicsMaterialSimple(const string &inName, ColorArg inColor) : mDebugName(inName), mDebugColor(inColor) { }
+											PhysicsMaterialSimple(const string_view &inName, ColorArg inColor) : mDebugName(inName), mDebugColor(inColor) { }
 
 	// Properties
 	virtual const char *					GetDebugName() const override		{ return mDebugName.c_str(); }

+ 1 - 1
Jolt/Physics/Collision/Shape/ConvexHullShape.cpp

@@ -56,7 +56,7 @@ ConvexHullShape::ConvexHullShape(const ConvexHullShapeSettings &inSettings, Shap
 	}
 
 	// Build convex hull
-	string error;
+	const char *error = nullptr;
 	ConvexHullBuilder builder(inSettings.mPoints);
 	ConvexHullBuilder::EResult result = builder.Initialize(cMaxPointsInHull, inSettings.mHullTolerance, error);
 	if (result != ConvexHullBuilder::EResult::Success && result != ConvexHullBuilder::EResult::MaxVerticesReached)

+ 2 - 2
Jolt/Physics/Collision/Shape/MeshShape.cpp

@@ -191,10 +191,10 @@ MeshShape::MeshShape(const MeshShapeSettings &inSettings, ShapeResult &outResult
 	// Convert to buffer
 	AABBTreeToBufferStats buffer_stats;
 	AABBTreeToBuffer<TriangleCodec, NodeCodec> buffer;
-	string error;
+	const char *error = nullptr;
 	if (!buffer.Convert(inSettings.mTriangleVertices, root, buffer_stats, error, EAABBTreeToBufferConvertMode::DepthFirstTrianglesLast))
 	{
-		outResult.SetError(move(error));
+		outResult.SetError(error);
 		delete root;
 		return;
 	}

+ 1 - 1
Jolt/Renderer/DebugRenderer.h

@@ -219,7 +219,7 @@ public:
 	void								DrawGeometry(Mat44Arg inModelMatrix, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode = ECullMode::CullBackFace, ECastShadow inCastShadow = ECastShadow::On, EDrawMode inDrawMode = EDrawMode::Solid) { DrawGeometry(inModelMatrix, inGeometry->mBounds.Transformed(inModelMatrix), max(max(inModelMatrix.GetAxisX().LengthSq(), inModelMatrix.GetAxisY().LengthSq()), inModelMatrix.GetAxisZ().LengthSq()), inModelColor, inGeometry, inCullMode, inCastShadow, inDrawMode); }
 
 	/// Draw text
-	virtual void						DrawText3D(Vec3Arg inPosition, const string &inString, ColorArg inColor = Color::sWhite, float inHeight = 0.5f)	= 0;
+	virtual void						DrawText3D(Vec3Arg inPosition, const string_view &inString, ColorArg inColor = Color::sWhite, float inHeight = 0.5f)	= 0;
 
 protected:
 	/// Initialize the system, must be called from the constructor of the DebugRenderer implementation

+ 1 - 1
Jolt/Renderer/DebugRendererRecorder.cpp

@@ -92,7 +92,7 @@ void DebugRendererRecorder::DrawGeometry(Mat44Arg inModelMatrix, const AABox &in
 	mCurrentFrame.mGeometries.push_back({ inModelMatrix, inModelColor, geometry_id, inCullMode, inCastShadow, inDrawMode });
 }
 
-void DebugRendererRecorder::DrawText3D(Vec3Arg inPosition, const string &inString, ColorArg inColor, float inHeight)
+void DebugRendererRecorder::DrawText3D(Vec3Arg inPosition, const string_view &inString, ColorArg inColor, float inHeight)
 { 	
 	lock_guard lock(mMutex);  
 

+ 4 - 1
Jolt/Renderer/DebugRendererRecorder.h

@@ -30,7 +30,7 @@ public:
 	virtual Batch						CreateTriangleBatch(const Triangle *inTriangles, int inTriangleCount) override;
 	virtual Batch						CreateTriangleBatch(const Vertex *inVertices, int inVertexCount, const uint32 *inIndices, int inIndexCount) override;
 	virtual void						DrawGeometry(Mat44Arg inModelMatrix, const AABox &inWorldSpaceBounds, float inLODScaleSq, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode, ECastShadow inCastShadow, EDrawMode inDrawMode) override;
-	virtual void						DrawText3D(Vec3Arg inPosition, const string &inString, ColorArg inColor, float inHeight) override;
+	virtual void						DrawText3D(Vec3Arg inPosition, const string_view &inString, ColorArg inColor, float inHeight) override;
 	
 	/// Mark the end of a frame
 	void								EndFrame();
@@ -64,6 +64,9 @@ public:
 	/// Holds a single text entry
 	struct TextBlob
 	{
+										TextBlob() = default;
+										TextBlob(Vec3Arg inPosition, const string_view &inString, const Color &inColor, float inHeight) : mPosition(inPosition), mString(inString), mColor(inColor), mHeight(inHeight) { }
+
 		Vec3							mPosition;
 		string							mString;
 		Color							mColor;

+ 13 - 10
Jolt/Skeleton/Skeleton.h

@@ -26,22 +26,25 @@ public:
 	public:
 		JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(Joint)
 
-		string				mName;																	///< Name of the joint
-		string				mParentName;															///< Name of parent joint
-		int					mParentJointIndex = -1;													///< Index of parent joint (in mJoints) or -1 if it has no parent
+							Joint() = default;
+							Joint(const string_view &inName, const string_view &inParentName, int inParentJointIndex) : mName(inName), mParentName(inParentName), mParentJointIndex(inParentJointIndex) { }
+
+		string				mName;																		///< Name of the joint
+		string				mParentName;																///< Name of parent joint
+		int					mParentJointIndex = -1;														///< Index of parent joint (in mJoints) or -1 if it has no parent
 	};
 
 	using JointVector = vector<Joint>;
 
 	///@name Access to the joints
 	///@{
-	const JointVector &		GetJoints() const														{ return mJoints; }
-	JointVector &			GetJoints()																{ return mJoints; }
-	int						GetJointCount() const													{ return (int)mJoints.size(); }
-	const Joint &			GetJoint(int inJoint) const												{ return mJoints[inJoint]; }
-	Joint &					GetJoint(int inJoint)													{ return mJoints[inJoint]; }
-	uint					AddJoint(const string &inName, const string &inParentName = string())	{ mJoints.push_back({ inName, inParentName, -1 }); return (uint)mJoints.size() - 1; }
-	uint					AddJoint(const string &inName, int inParentIndex)						{ mJoints.push_back({ inName, inParentIndex >= 0? mJoints[inParentIndex].mName : string(), inParentIndex }); return (uint)mJoints.size() - 1; }
+	const JointVector &		GetJoints() const															{ return mJoints; }
+	JointVector &			GetJoints()																	{ return mJoints; }
+	int						GetJointCount() const														{ return (int)mJoints.size(); }
+	const Joint &			GetJoint(int inJoint) const													{ return mJoints[inJoint]; }
+	Joint &					GetJoint(int inJoint)														{ return mJoints[inJoint]; }
+	uint					AddJoint(const string_view &inName, const string_view &inParentName = string_view()) { mJoints.emplace_back(inName, inParentName, -1); return (uint)mJoints.size() - 1; }
+	uint					AddJoint(const string_view &inName, int inParentIndex)						{ mJoints.emplace_back(inName, inParentIndex >= 0? mJoints[inParentIndex].mName : string(), inParentIndex); return (uint)mJoints.size() - 1; }
 	///@}
 
 	/// Find joint by name

+ 2 - 2
Samples/Tests/ConvexCollision/ConvexHullTest.cpp

@@ -473,11 +473,11 @@ void ConvexHullTest::PrePhysicsUpdate(const PreUpdateParams &inParams)
 	ConvexHullBuilder builder(points);
 
 	// Build the hull
-	string error;
+	const char *error = nullptr;
 	ConvexHullBuilder::EResult result = builder.Initialize(INT_MAX, tolerance, error);
 	if (result != ConvexHullBuilder::EResult::Success && result != ConvexHullBuilder::EResult::MaxVerticesReached)
 	{
-		Trace("Iteration %d: Failed to initialize from positions: %s", mIteration - 1, error.c_str());
+		Trace("Iteration %d: Failed to initialize from positions: %s", mIteration - 1, error);
 		JPH_ASSERT(false);
 		return;
 	}

+ 1 - 1
Samples/Tests/General/FrictionPerTriangleTest.h

@@ -24,7 +24,7 @@ public:
 		// Note: Not implementing serialization because we don't serialize this material in this example!
 
 		/// Constructor
-					MyMaterial(const string &inName, ColorArg inColor, float inFriction, float inRestitution) : PhysicsMaterialSimple(inName, inColor), mFriction(inFriction), mRestitution(inRestitution) { }
+					MyMaterial(const string_view &inName, ColorArg inColor, float inFriction, float inRestitution) : PhysicsMaterialSimple(inName, inColor), mFriction(inFriction), mRestitution(inRestitution) { }
 
 		float		mFriction;
 		float		mRestitution;

+ 5 - 5
TestFramework/Application/DebugUI.cpp

@@ -59,7 +59,7 @@ UIElement *DebugUI::CreateMenu()
 	return stack;
 }
 
-UIStaticText *DebugUI::CreateStaticText(UIElement *inMenu, const string &inText)
+UIStaticText *DebugUI::CreateStaticText(UIElement *inMenu, const string_view &inText)
 {
 	UIStaticText *text = new UIStaticText();
 	text->SetText(inText);
@@ -68,7 +68,7 @@ UIStaticText *DebugUI::CreateStaticText(UIElement *inMenu, const string &inText)
 	return text;
 }
 
-UITextButton *DebugUI::CreateTextButton(UIElement *inMenu, const string &inName, UITextButton::ClickAction inAction)
+UITextButton *DebugUI::CreateTextButton(UIElement *inMenu, const string_view &inName, UITextButton::ClickAction inAction)
 {
 	UITextButton *button = new UITextButton();
 	button->SetText(inName);
@@ -80,7 +80,7 @@ UITextButton *DebugUI::CreateTextButton(UIElement *inMenu, const string &inName,
 	return button;
 }
 
-UICheckBox *DebugUI::CreateCheckBox(UIElement *inMenu, const string &inName, bool inInitiallyChecked, UICheckBox::ClickAction inAction)
+UICheckBox *DebugUI::CreateCheckBox(UIElement *inMenu, const string_view &inName, bool inInitiallyChecked, UICheckBox::ClickAction inAction)
 {
 	UICheckBox *check_box = new UICheckBox();
 	check_box->SetUncheckedStateQuad(UITexturedQuad(mUITexture, 48, 0, 16, 16));
@@ -94,7 +94,7 @@ UICheckBox *DebugUI::CreateCheckBox(UIElement *inMenu, const string &inName, boo
 	return check_box;
 }
 
-UISlider *DebugUI::CreateSlider(UIElement *inMenu, const string &inName, float inInitialValue, float inMinValue, float inMaxValue, float inStepValue, UISlider::ValueChangedAction inAction)
+UISlider *DebugUI::CreateSlider(UIElement *inMenu, const string_view &inName, float inInitialValue, float inMinValue, float inMaxValue, float inStepValue, UISlider::ValueChangedAction inAction)
 {
 	UIHorizontalStack *horiz = new UIHorizontalStack();
 	horiz->SetPaddingRight(24);
@@ -146,7 +146,7 @@ UISlider *DebugUI::CreateSlider(UIElement *inMenu, const string &inName, float i
 	return slider;
 }
 
-UIComboBox *DebugUI::CreateComboBox(UIElement *inMenu, const string &inName, const vector<string> &inItems, int inInitialItem, UIComboBox::ItemChangedAction inAction)
+UIComboBox *DebugUI::CreateComboBox(UIElement *inMenu, const string_view &inName, const vector<string> &inItems, int inInitialItem, UIComboBox::ItemChangedAction inAction)
 {
 	UIHorizontalStack *horiz = new UIHorizontalStack();
 	horiz->SetPaddingRight(24);

+ 5 - 5
TestFramework/Application/DebugUI.h

@@ -25,11 +25,11 @@ public:
 	UIElement *			CreateMenu();
 
 	/// Add items to the menu
-	UIStaticText *		CreateStaticText(UIElement *inMenu, const string &inText);
-	UITextButton *		CreateTextButton(UIElement *inMenu, const string &inName, UITextButton::ClickAction inAction);
-	UICheckBox *		CreateCheckBox(UIElement *inMenu, const string &inName, bool inInitiallyChecked, UICheckBox::ClickAction inAction);
-	UISlider *			CreateSlider(UIElement *inMenu, const string &inName, float inInitialValue, float inMinValue, float inMaxValue, float inStepValue, UISlider::ValueChangedAction inAction);
-	UIComboBox *		CreateComboBox(UIElement *inMenu, const string &inName, const vector<string> &inItems, int inInitialItem, UIComboBox::ItemChangedAction inAction);
+	UIStaticText *		CreateStaticText(UIElement *inMenu, const string_view &inText);
+	UITextButton *		CreateTextButton(UIElement *inMenu, const string_view &inName, UITextButton::ClickAction inAction);
+	UICheckBox *		CreateCheckBox(UIElement *inMenu, const string_view &inName, bool inInitiallyChecked, UICheckBox::ClickAction inAction);
+	UISlider *			CreateSlider(UIElement *inMenu, const string_view &inName, float inInitialValue, float inMinValue, float inMaxValue, float inStepValue, UISlider::ValueChangedAction inAction);
+	UIComboBox *		CreateComboBox(UIElement *inMenu, const string_view &inName, const vector<string> &inItems, int inInitialItem, UIComboBox::ItemChangedAction inAction);
 
 	/// Show it
 	void				ShowMenu(UIElement *inMenu);

+ 1 - 1
TestFramework/Renderer/DebugRendererImp.cpp

@@ -226,7 +226,7 @@ void DebugRendererImp::DrawInstances(const Geometry *inGeometry, const vector<in
 	}
 }
 
-void DebugRendererImp::DrawText3D(Vec3Arg inPosition, const string &inString, ColorArg inColor, float inHeight)
+void DebugRendererImp::DrawText3D(Vec3Arg inPosition, const string_view &inString, ColorArg inColor, float inHeight)
 { 	
 	lock_guard lock(mTextsLock);  
 	mTexts.emplace_back(inPosition, inString, inColor, inHeight); 

+ 2 - 2
TestFramework/Renderer/DebugRendererImp.h

@@ -33,7 +33,7 @@ public:
 	virtual Batch						CreateTriangleBatch(const Triangle *inTriangles, int inTriangleCount) override;
 	virtual Batch						CreateTriangleBatch(const Vertex *inVertices, int inVertexCount, const uint32 *inIndices, int inIndexCount) override;
 	virtual void						DrawGeometry(Mat44Arg inModelMatrix, const AABox &inWorldSpaceBounds, float inLODScaleSq, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode, ECastShadow inCastShadow, EDrawMode inDrawMode) override;
-	virtual void						DrawText3D(Vec3Arg inPosition, const string &inString, ColorArg inColor, float inHeight) override;
+	virtual void						DrawText3D(Vec3Arg inPosition, const string_view &inString, ColorArg inColor, float inHeight) override;
 	
 	/// Draw all primitives that were added
 	void								Draw();
@@ -150,7 +150,7 @@ private:
 	/// A single text string
 	struct Text
 	{
-										Text(Vec3Arg inPosition, const string &inText, ColorArg inColor, float inHeight) : mPosition(inPosition), mText(inText), mColor(inColor), mHeight(inHeight) { }
+										Text(Vec3Arg inPosition, const string_view &inText, ColorArg inColor, float inHeight) : mPosition(inPosition), mText(inText), mColor(inColor), mHeight(inHeight) { }
 
 		Vec3							mPosition;
 		string							mText;

+ 3 - 3
TestFramework/Renderer/Font.cpp

@@ -219,7 +219,7 @@ Font::Create(const char *inFontName, int inCharHeight)
 	return true;
 }
 
-Float2 Font::MeasureText(const string &inText) const
+Float2 Font::MeasureText(const string_view &inText) const
 {
 	JPH_PROFILE("MeasureText");
 
@@ -264,7 +264,7 @@ Float2 Font::MeasureText(const string &inText) const
 	return extents;
 }
 	
-bool Font::CreateString(Mat44Arg inTransform, const string &inText, ColorArg inColor, RenderPrimitive &ioPrimitive) const
+bool Font::CreateString(Mat44Arg inTransform, const string_view &inText, ColorArg inColor, RenderPrimitive &ioPrimitive) const
 {
 	JPH_PROFILE("CreateString");
 
@@ -387,7 +387,7 @@ bool Font::CreateString(Mat44Arg inTransform, const string &inText, ColorArg inC
 	return true;
 }
 
-void Font::DrawText3D(Mat44Arg inTransform, const string &inText, ColorArg inColor) const
+void Font::DrawText3D(Mat44Arg inTransform, const string_view &inText, ColorArg inColor) const
 {
 	JPH_PROFILE("DrawText3D");
 

+ 3 - 3
TestFramework/Renderer/Font.h

@@ -33,16 +33,16 @@ public:
 	int							GetCharHeight() const								{ return mCharHeight; }
 							
 	/// Get extents of a string, assuming the height of the text is 1 and with the normal aspect ratio of the font
-	Float2						MeasureText(const string &inText) const;
+	Float2						MeasureText(const string_view &inText) const;
 
 	/// Draw a string at a specific location
 	/// If the string is drawn with the identity matrix, it's top left will start at (0, 0, 0)
 	/// The text width is in the X direction and the text height is in the Y direction and it will have a height of 1
-	void						DrawText3D(Mat44Arg inTransform, const string &inText, ColorArg inColor = Color::sWhite) const;
+	void						DrawText3D(Mat44Arg inTransform, const string_view &inText, ColorArg inColor = Color::sWhite) const;
 							
 private:
 	/// Create a primitive for a string
-	bool						CreateString(Mat44Arg inTransform, const string &inText, ColorArg inColor, RenderPrimitive &ioPrimitive) const;
+	bool						CreateString(Mat44Arg inTransform, const string_view &inText, ColorArg inColor, RenderPrimitive &ioPrimitive) const;
 
 	struct FontVertex
 	{

+ 1 - 1
TestFramework/UI/UIManager.cpp

@@ -328,7 +328,7 @@ void UIManager::DrawQuad(int inX, int inY, int inWidth, int inHeight, const UITe
 	}
 }
 
-void UIManager::DrawText(int inX, int inY, const string &inText, const Font *inFont, ColorArg inColor)
+void UIManager::DrawText(int inX, int inY, const string_view &inText, const Font *inFont, ColorArg inColor)
 {
 	Vec4 pos(float(inX), float(inY), 0.0f, 1.0f);
 	Vec4 right(float(inFont->GetCharHeight()), 0.0f, 0.0f, 0.0f);

+ 1 - 1
TestFramework/UI/UIManager.h

@@ -67,7 +67,7 @@ public:
 	void						DrawQuad(int inX, int inY, int inWidth, int inHeight, const UITexturedQuad &inQuad, ColorArg inColor);
 
 	/// Draw a string in screen coordinates (assumes that the projection matrix has been set up correctly)
-	void						DrawText(int inX, int inY, const string &inText, const Font *inFont, ColorArg inColor = Color::sWhite);
+	void						DrawText(int inX, int inY, const string_view &inText, const Font *inFont, ColorArg inColor = Color::sWhite);
 								
 private:
 	Renderer *					mRenderer;

+ 1 - 1
TestFramework/UI/UIStaticText.h

@@ -19,7 +19,7 @@ public:
 	void				SetTextColor(ColorArg inColor)				{ mTextColor = inColor; }
 	void				SetDisabledTextColor(ColorArg inColor)		{ mDisabledTextColor = inColor; }
 	void				SetFont(const Font *inFont)					{ mFont = inFont; }
-	void				SetText(const string &inText)				{ mText = inText; }
+	void				SetText(const string_view &inText)			{ mText = inText; }
 	void				SetTextPadding(int inTop, int inLeft, int inBottom, int inRight) { mTextPadTop = inTop; mTextPadLeft = inLeft; mTextPadBottom = inBottom; mTextPadRight = inRight; }
 	void				SetTextAlignment(EAlignment inAlignment)	{ JPH_ASSERT(inAlignment == LEFT || inAlignment == RIGHT || inAlignment == CENTER); mTextAlignment = inAlignment; }
 	void				SetWrap(bool inWrap)						{ mWrap = inWrap; }

+ 4 - 4
UnitTests/Geometry/ConvexHullBuilderTest.cpp

@@ -12,7 +12,7 @@ TEST_SUITE("ConvexHullBuilderTest")
 
 	TEST_CASE("TestDegenerate")
 	{
-		string error;
+		const char *error = nullptr;
 
 		{
 			// Too few points / coinciding points should be degenerate
@@ -41,7 +41,7 @@ TEST_SUITE("ConvexHullBuilderTest")
 
 	TEST_CASE("Test2DHull")
 	{
-		string error;
+		const char *error = nullptr;
 
 		{
 			// A triangle
@@ -92,7 +92,7 @@ TEST_SUITE("ConvexHullBuilderTest")
 
 	TEST_CASE("Test3DHull")
 	{
-		string error;
+		const char *error = nullptr;
 
 		{
 			// A cube with lots of interior points
@@ -142,7 +142,7 @@ TEST_SUITE("ConvexHullBuilderTest")
 
 	TEST_CASE("TestRandomHull")
 	{
-		string error;
+		const char *error = nullptr;
 
 		UnitTestRandom random(0x1ee7c0de);