[Bf-blender-cvs] [be980c4] master: Freestyle: minor optimization for space by using a pointer to a const char array instead of std::string.

Tamito Kajiyama noreply at git.blender.org
Mon Jul 20 01:11:43 CEST 2015


Commit: be980c4ee46ca8b9eb8e0492cf8dd06ec8426348
Author: Tamito Kajiyama
Date:   Fri Jul 25 12:23:09 2014 +0900
Branches: master
https://developer.blender.org/rBbe980c4ee46ca8b9eb8e0492cf8dd06ec8426348

Freestyle: minor optimization for space by using a pointer to a const char array instead of std::string.

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

M	source/blender/freestyle/intern/python/BPy_SShape.cpp
M	source/blender/freestyle/intern/python/BPy_ViewShape.cpp
M	source/blender/freestyle/intern/scene_graph/Rep.h
M	source/blender/freestyle/intern/view_map/Silhouette.h
M	source/blender/freestyle/intern/view_map/ViewMap.h
M	source/blender/freestyle/intern/winged_edge/WEdge.h

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

diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index 11ed07d..9169adf 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -185,7 +185,7 @@ PyDoc_STRVAR(SShape_name_doc,
 
 static PyObject *SShape_name_get(BPy_SShape *self, void *UNUSED(closure))
 {
-	return PyUnicode_FromString(self->ss->getName().c_str());
+	return PyUnicode_FromString(self->ss->getName());
 }
 
 static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closure))
@@ -194,7 +194,7 @@ static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closu
 		PyErr_SetString(PyExc_TypeError, "value must be a string");
 		return -1;
 	}
-	const string name = _PyUnicode_AsString(value);
+	const char *name = _PyUnicode_AsString(value);
 	self->ss->setName(name);
 	return 0;
 }
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index d933d9f..253bf27 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -293,7 +293,7 @@ PyDoc_STRVAR(ViewShape_name_doc,
 
 static PyObject *ViewShape_name_get(BPy_ViewShape *self, void *UNUSED(closure))
 {
-	return PyUnicode_FromString(self->vs->getName().c_str());
+	return PyUnicode_FromString(self->vs->getName());
 }
 
 PyDoc_STRVAR(ViewShape_id_doc,
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index 88ee0d2..9917af3 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -127,7 +127,7 @@ public:
 		return _Id;
 	}
 
-	inline const string& getName() const
+	inline const char *getName() const
 	{
 		return _Name;
 	}
@@ -148,7 +148,7 @@ public:
 		_Id = id;
 	}
 
-	inline void setName(const string& name)
+	inline void setName(const char *name)
 	{
 		_Name = name;
 	}
@@ -161,7 +161,7 @@ public:
 private:
 	BBox<Vec3r> _BBox;
 	Id _Id;
-	string _Name;
+	const char *_Name;
 	FrsMaterial *_FrsMaterial;
 };
 
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index a80fea0..0b20c9f 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -1415,7 +1415,7 @@ private:
 	vector<SVertex*> _verticesList;  // list of all vertices
 	vector<FEdge*> _edgesList;       // list of all edges
 	Id _Id;
-	string _Name;
+	const char *_Name;
 	BBox<Vec3r> _BBox;
 	vector<FrsMaterial> _FrsMaterials;  
 
@@ -1435,6 +1435,7 @@ public:
 		userdata = NULL;
 		_importance = 0.0f;
 		_ViewShape = NULL;
+		_Name = NULL;
 	}
 
 	/*! Copy constructor */
@@ -1887,7 +1888,7 @@ public:
 	}
 
 	/*! Returns the name of the Shape. */
-	inline const string& getName() const
+	inline const char *getName() const
 	{
 		return _Name;
 	}
@@ -1900,7 +1901,7 @@ public:
 	}
 
 	/*! Sets the name of the shape.*/
-	inline void setName(const string& name)
+	inline void setName(const char *name)
 	{
 		_Name = name;
 	}
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 0ee1864..74297e1 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -1566,7 +1566,7 @@ public:
 	}
 
 	/*! Returns the ViewShape id. */
-	inline const string& getName() const
+	inline const char *getName() const
 	{
 		return _SShape->getName();
 	}
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index 41525e0..97c282e 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -1025,7 +1025,7 @@ protected:
 	vector<WEdge *> _EdgeList;
 	vector<WFace *> _FaceList;
 	int _Id;
-	string _Name;
+	const char *_Name;
 	static unsigned _SceneCurrentId;
 	Vec3r _min;
 	Vec3r _max;
@@ -1113,7 +1113,7 @@ public:
 		return _meanEdgeSize;
 	}
 
-	inline const string& getName() const
+	inline const char *getName() const
 	{
 		return _Name;
 	}
@@ -1160,7 +1160,7 @@ public:
 		_FrsMaterials = iMaterials;
 	}
 
-	inline void setName(const string& name)
+	inline void setName(const char *name)
 	{
 		_Name = name;
 	}




More information about the Bf-blender-cvs mailing list