Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-03 15:59:27 +0300
committerJacques Lucke <jacques@blender.org>2020-07-03 15:59:27 +0300
commit2633683b52054d15006aea1314f62f73a8505b42 (patch)
treea97b2916170b53f04fc9a898f4eedb527f14f84e
parent93da09d717ff4502975c506c574faf0c07f010b4 (diff)
Clang-tidy: enable readability-container-size-empty warning
Reviewers: sergey Differential Revision: https://developer.blender.org/D8197
-rw-r--r--.clang-tidy1
-rw-r--r--source/blender/blenkernel/intern/volume.cc2
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp8
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.cpp4
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp6
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp12
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_hair.cc4
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mesh.cc2
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc4
-rw-r--r--source/blender/io/collada/AnimationExporter.cpp10
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp14
-rw-r--r--source/blender/io/collada/ArmatureImporter.cpp4
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp4
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp25
-rw-r--r--source/blender/io/collada/MeshImporter.cpp8
-rw-r--r--source/blender/io/collada/SkinInfo.cpp2
-rw-r--r--source/blender/io/collada/collada_internal.cpp2
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator.cc12
23 files changed, 67 insertions, 67 deletions
diff --git a/.clang-tidy b/.clang-tidy
index f901ba837cb..7d8d4e9c3c0 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -25,7 +25,6 @@ Checks: >
-readability-redundant-string-init,
-readability-redundant-member-init,
-readability-const-return-type,
- -readability-container-size-empty,
-readability-redundant-string-cstr,
-readability-static-accessed-through-instance,
-readability-redundant-declaration,
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 26c5810aefa..39c04d117e2 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -152,7 +152,7 @@ static struct VolumeFileCache {
~VolumeFileCache()
{
- assert(cache.size() == 0);
+ assert(cache.empty());
}
Entry *add_metadata_user(const Entry &template_entry)
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 92e64c33d4d..f4da16efd22 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -184,7 +184,7 @@ bool WorkScheduler::hasGPUDevices()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
# ifdef COM_OPENCL_ENABLED
- return g_gpudevices.size() > 0;
+ return !g_gpudevices.empty();
# else
return 0;
# endif
@@ -210,7 +210,7 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
if (g_cpudevices.size() != num_cpu_threads) {
Device *device;
- while (g_cpudevices.size() > 0) {
+ while (!g_cpudevices.empty()) {
device = g_cpudevices.back();
g_cpudevices.pop_back();
device->deinitialize();
@@ -331,7 +331,7 @@ void WorkScheduler::deinitialize()
/* deinitialize CPU threads */
if (g_cpuInitialized) {
Device *device;
- while (g_cpudevices.size() > 0) {
+ while (!g_cpudevices.empty()) {
device = g_cpudevices.back();
g_cpudevices.pop_back();
device->deinitialize();
@@ -345,7 +345,7 @@ void WorkScheduler::deinitialize()
/* deinitialize OpenCL GPU's */
if (g_openclInitialized) {
Device *device;
- while (g_gpudevices.size() > 0) {
+ while (!g_gpudevices.empty()) {
device = g_gpudevices.back();
g_gpudevices.pop_back();
device->deinitialize();
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 253d62ea3dc..dfe78eaf10c 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -469,7 +469,7 @@ void Controller::DeleteViewMap(bool freeCache)
void Controller::ComputeViewMap()
{
- if (!_ListOfModels.size()) {
+ if (_ListOfModels.empty()) {
return;
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index 996906826e9..0af57e5d728 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -746,7 +746,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
detriList.push_back(detri);
}
- if (detriList.size() > 0) {
+ if (!detriList.empty()) {
vector<detri_t>::iterator v;
for (v = detriList.begin(); v != detriList.end(); v++) {
detri_t detri = (*v);
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp
index e3e25796de1..46e91197764 100644
--- a/source/blender/freestyle/intern/geometry/Grid.cpp
+++ b/source/blender/freestyle/intern/geometry/Grid.cpp
@@ -93,7 +93,7 @@ bool firstIntersectionGridVisitor::stop()
/////////////////
void Grid::clear()
{
- if (_occluders.size() != 0) {
+ if (!_occluders.empty()) {
for (OccludersSet::iterator it = _occluders.begin(); it != _occluders.end(); it++) {
delete (*it);
}
@@ -154,7 +154,7 @@ void Grid::configure(const Vec3r &orig, const Vec3r &size, unsigned nb)
void Grid::insertOccluder(Polygon3r *occluder)
{
const vector<Vec3r> vertices = occluder->getVertices();
- if (vertices.size() == 0) {
+ if (vertices.empty()) {
return;
}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.cpp b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
index e55b2fb625f..cf7a609b347 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
@@ -27,7 +27,7 @@ NodeShape::~NodeShape()
{
vector<Rep *>::iterator rep;
- if (0 != _Shapes.size()) {
+ if (!_Shapes.empty()) {
for (rep = _Shapes.begin(); rep != _Shapes.end(); ++rep) {
int refCount = (*rep)->destroy();
if (0 == refCount) {
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index c3c43ce6722..b7de3a5b319 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -633,7 +633,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
wFaces.clear();
}
- if (iRenderMonitor && vedges.size()) {
+ if (iRenderMonitor && !vedges.empty()) {
stringstream ss;
ss << "Freestyle: Visibility computations " << (100 * cnt / vedges.size()) << "%";
iRenderMonitor->setInfo(ss.str());
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp b/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
index 8357231a73d..ef79384e2af 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
@@ -25,7 +25,7 @@ namespace Freestyle {
NodeGroup *ViewMapTesselator::Tesselate(ViewMap *iViewMap)
{
- if (0 == iViewMap->ViewEdges().size()) {
+ if (iViewMap->ViewEdges().empty()) {
return NULL;
}
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
index 620601df5e7..63f65988fc9 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
@@ -200,7 +200,7 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
delete[] new_vertices;
delete[] new_normals;
- if (shape.GetFaceList().size() == 0) { // this may happen due to degenerate triangles
+ if (shape.GetFaceList().empty()) { // this may happen due to degenerate triangles
return false;
}
@@ -219,8 +219,8 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
if ((*wv)->isBoundary()) {
continue;
}
- if ((*wv)->GetEdges().size() ==
- 0) { // This means that the WVertex has no incoming edges... (12-Sep-2011 T.K.)
+ if ((*wv)->GetEdges().empty()) {
+ // This means that the WVertex has no incoming edges... (12-Sep-2011 T.K.)
continue;
}
normalsSet.clear();
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 0555d213b3f..2a5532a0902 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -816,7 +816,7 @@ void IMB_exr_add_channel(void *handle,
if (layname && layname[0] != '\0') {
imb_exr_insert_view_name(echan->name, echan->m->name.c_str(), echan->m->view.c_str());
}
- else if (data->multiView->size() >= 1) {
+ else if (!data->multiView->empty()) {
std::string raw_name = insertViewName(echan->m->name, *data->multiView, echan->view_id);
BLI_strncpy(echan->name, raw_name.c_str(), sizeof(echan->name));
}
@@ -1066,7 +1066,7 @@ float *IMB_exr_channel_rect(void *handle,
imb_exr_insert_view_name(temp_buf, name, viewname);
BLI_strncpy(name, temp_buf, sizeof(name));
}
- else if (data->multiView->size() >= 1) {
+ else if (!data->multiView->empty()) {
const int view_id = std::max(0, imb_exr_get_multiView_id(*data->multiView, viewname));
std::string raw_name = insertViewName(name, *data->multiView, view_id);
BLI_strncpy(name, raw_name.c_str(), sizeof(name));
@@ -1300,7 +1300,7 @@ void IMB_exr_multilayer_convert(void *handle,
ExrPass *pass;
/* RenderResult needs at least one RenderView */
- if (data->multiView->size() == 0) {
+ if (data->multiView->empty()) {
addview(base, "");
}
else {
@@ -1775,7 +1775,7 @@ static bool imb_exr_is_multilayer_file(MultiPartInputFile &file)
* channels without a layer name will be single layer. */
channels.layers(layerNames);
- return (layerNames.size() > 0);
+ return (!layerNames.empty());
}
static void imb_exr_type_by_channels(ChannelList &channels,
@@ -1792,7 +1792,7 @@ static void imb_exr_type_by_channels(ChannelList &channels,
/* will not include empty layer names */
channels.layers(layerNames);
- if (views.size() && views[0] != "") {
+ if (!views.empty() && !views[0].empty()) {
*r_multiview = true;
}
else {
@@ -1802,7 +1802,7 @@ static void imb_exr_type_by_channels(ChannelList &channels,
return;
}
- if (layerNames.size()) {
+ if (!layerNames.empty()) {
/* if layerNames is not empty, it means at least one layer is non-empty,
* but it also could be layers without names in the file and such case
* shall be considered a multilayer exr
diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc
index ac4deddd9b4..f9b4619b263 100644
--- a/source/blender/io/alembic/exporter/abc_writer_hair.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc
@@ -282,10 +282,10 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context,
norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1]));
}
else {
- if (uv_values.size()) {
+ if (!uv_values.empty()) {
uv_values.push_back(uv_values[pc->parent]);
}
- if (norm_values.size()) {
+ if (!norm_values.empty()) {
norm_values.push_back(norm_values[pc->parent]);
}
}
diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
index 07196f2b81f..89cb76db9a6 100644
--- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
@@ -443,7 +443,7 @@ void ABCGenericMeshWriter::get_geo_groups(Object *object,
geo_groups[name].push_back(i);
}
- if (geo_groups.size() == 0) {
+ if (geo_groups.empty()) {
Material *mat = BKE_object_material_get(object, 1);
std::string name = (mat) ? args_.hierarchy_iterator->get_id_name(&mat->id) : "default";
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index 5932791ecf4..7cde2d4fe73 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -373,7 +373,7 @@ static std::pair<bool, AbcObjectReader *> visit_object(
}
}
else if (object.getParent()) {
- if (claiming_child_readers.size() > 0) {
+ if (!claiming_child_readers.empty()) {
/* The first claiming child will serve just fine as parent to
* our non-claiming children. Since all claiming children share
* the same XForm, it doesn't really matter which one we pick. */
@@ -479,7 +479,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
visit_object(archive->getTop(), data->readers, data->settings, assign_as_parent);
/* There shouldn't be any orphans. */
- BLI_assert(assign_as_parent.size() == 0);
+ BLI_assert(assign_as_parent.empty());
if (G.is_break) {
data->was_cancelled = true;
diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp
index 9f0c1924bb9..c25b4ea543b 100644
--- a/source/blender/io/collada/AnimationExporter.cpp
+++ b/source/blender/io/collada/AnimationExporter.cpp
@@ -222,7 +222,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
std::vector<float> frames;
sampler.get_object_frames(frames, ob);
- if (frames.size() > 0) {
+ if (!frames.empty()) {
BCMatrixSampleMap samples;
bool is_animated = sampler.get_object_samples(samples, ob);
if (keep_flat_curves || is_animated) {
@@ -264,7 +264,7 @@ void AnimationExporter::export_bone_animations_recursive(Object *ob,
std::vector<float> frames;
sampler.get_bone_frames(frames, ob, bone);
- if (frames.size()) {
+ if (!frames.empty()) {
BCMatrixSampleMap samples;
bool is_animated = sampler.get_bone_samples(samples, ob, bone);
if (keep_flat_curves || is_animated) {
@@ -542,7 +542,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
param.push_back("ANGLE");
}
else {
- if (axis != "") {
+ if (!axis.empty()) {
param.push_back(axis);
}
else if (transform) {
@@ -836,11 +836,11 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
bool is_angle = curve.is_rotation_curve();
- if (tm_name.size()) {
+ if (!tm_name.empty()) {
if (is_angle) {
return tm_name + std::string(axis_name) + ".ANGLE";
}
- else if (axis_name != "") {
+ else if (!axis_name.empty()) {
return tm_name + "." + std::string(axis_name);
}
else {
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index 1de86425521..0e211f08d1f 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -52,7 +52,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
@@ -277,7 +277,7 @@ AnimationImporter::~AnimationImporter()
BKE_fcurve_free(*it);
}
- if (unused_curves.size()) {
+ if (!unused_curves.empty()) {
fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
}
}
@@ -738,7 +738,7 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
/* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
* Reason: old blender versions stored spot_size in radians (was a bug)
*/
- if (this->import_from_version == "" ||
+ if (this->import_from_version.empty() ||
BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) {
fcurve_deg_to_rad(fcu);
}
@@ -878,7 +878,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
newcu[i]->totvert = frames.size();
}
- if (frames.size() == 0) {
+ if (frames.empty()) {
return;
}
@@ -1333,7 +1333,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
newcu[i]->totvert = frames.size();
}
- if (frames.size() == 0) {
+ if (frames.empty()) {
return;
}
@@ -1641,7 +1641,7 @@ Object *AnimationImporter::translate_animation_OLD(
job = get_joint_object(root, node, par_job);
#endif
- if (frames.size() == 0) {
+ if (frames.empty()) {
return job;
}
@@ -1876,7 +1876,7 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4],
unit_m4(m);
- std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+ std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName();
if (!evaluate_animation(tm, m, fra, nodename.c_str())) {
switch (type) {
case COLLADAFW::Transformation::ROTATE:
diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp
index a69500432e8..3755b71f300 100644
--- a/source/blender/io/collada/ArmatureImporter.cpp
+++ b/source/blender/io/collada/ArmatureImporter.cpp
@@ -41,7 +41,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
ArmatureImporter::ArmatureImporter(UnitConverter *conv,
@@ -606,7 +606,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
}
}
- if (!shared && this->joint_parent_map.size() > 0) {
+ if (!shared && !this->joint_parent_map.empty()) {
/* All armatures have been created while creating the Node tree.
* The Collada exporter currently does not create a
* strict relationship between geometries and armatures
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index 4aea74cd82f..f44e3e8385d 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -78,7 +78,7 @@ void BCAnimationSampler::add_object(Object *ob)
BCAnimationCurveMap *BCAnimationSampler::get_curves(Object *ob)
{
BCAnimation &animation = *objects[ob];
- if (animation.curve_map.size() == 0) {
+ if (animation.curve_map.empty()) {
initialize_curves(animation.curve_map, ob);
}
return &animation.curve_map;
@@ -279,7 +279,7 @@ void BCAnimationSampler::find_depending_animated(std::set<Object *> &animated_ob
break;
}
}
- } while (found_more && candidates.size() > 0);
+ } while (found_more && !candidates.empty());
}
void BCAnimationSampler::get_animated_from_export_set(std::set<Object *> &animated_objects,
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index 2305072a6eb..0f84db79c28 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -251,7 +251,7 @@ void DocumentImporter::finish()
}
}
- if (libnode_ob.size()) {
+ if (!libnode_ob.empty()) {
fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
/* free all library_nodes */
@@ -667,7 +667,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
++it) {
ob = *it;
- std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+ std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName();
BKE_libblock_rename(bmain, &ob->id, (char *)nodename.c_str());
object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
node_map[node->getUniqueId()] = node;
@@ -699,11 +699,11 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
- if (objects_done->size() > 0) {
- ob = *objects_done->begin();
+ if (objects_done->empty()) {
+ ob = NULL;
}
else {
- ob = NULL;
+ ob = *objects_done->begin();
}
for (unsigned int i = 0; i < child_nodes.getCount(); i++) {
@@ -792,7 +792,8 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
}
Main *bmain = CTX_data_main(mContext);
- const std::string &str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
+ const std::string &str_mat_id = cmat->getName().empty() ? cmat->getOriginalId() :
+ cmat->getName();
Material *ma = BKE_material_add(bmain, (char *)str_mat_id.c_str());
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
@@ -880,11 +881,11 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
ExtraTags *et = getExtraTags(camera->getUniqueId());
cam_id = camera->getOriginalId();
cam_name = camera->getName();
- if (cam_name.size()) {
- cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str());
+ if (cam_name.empty()) {
+ cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str());
}
else {
- cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str());
+ cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str());
}
if (!cam) {
@@ -1042,11 +1043,11 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
la_id = light->getOriginalId();
la_name = light->getName();
- if (la_name.size()) {
- lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str());
+ if (la_name.empty()) {
+ lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str());
}
else {
- lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str());
+ lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str());
}
if (!lamp) {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 6683f07bf65..495af60488b 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -50,7 +50,7 @@
// get node name, or fall back to original id if not present (name is optional)
template<class T> static const std::string bc_get_dae_name(T *node)
{
- return node->getName().size() ? node->getName() : node->getOriginalId();
+ return node->getName().empty() ? node->getOriginalId() : node->getName();
}
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
@@ -1126,7 +1126,7 @@ Object *MeshImporter::create_mesh_object(
}
// name Object
- const std::string &id = node->getName().size() ? node->getName() : node->getOriginalId();
+ const std::string &id = node->getName().empty() ? node->getOriginalId() : node->getName();
const char *name = (id.length()) ? id.c_str() : NULL;
// add object
@@ -1185,8 +1185,8 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
return true;
}
- const std::string &str_geom_id = mesh->getName().size() ? mesh->getName() :
- mesh->getOriginalId();
+ const std::string &str_geom_id = mesh->getName().empty() ? mesh->getOriginalId() :
+ mesh->getName();
Mesh *me = BKE_mesh_add(m_bmain, (char *)str_geom_id.c_str());
id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object
diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp
index 317e0b37796..5692d11d0c3 100644
--- a/source/blender/io/collada/SkinInfo.cpp
+++ b/source/blender/io/collada/SkinInfo.cpp
@@ -49,7 +49,7 @@
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
- return id.size() ? id.c_str() : node->getOriginalId().c_str();
+ return id.empty() ? node->getOriginalId().c_str() : id.c_str();
}
/* This is used to store data passed in write_controller_data.
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index 7e834045795..f123e8ea31f 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -221,7 +221,7 @@ std::string translate_id(const char *idString)
std::string translate_id(const std::string &id)
{
- if (id.size() == 0) {
+ if (id.empty()) {
return id;
}
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
index 9a456bfaf69..dce6b8e178b 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
@@ -219,18 +219,18 @@ void AbstractHierarchyIterator::debug_print_export_graph(const ExportGraph &grap
printf(" - %s%s%s\n",
child_ctx->object->id.name + 2,
child_ctx->weak_export ? " (weak)" : "",
- child_ctx->original_export_path.size() ?
- (std::string("ref ") + child_ctx->original_export_path).c_str() :
- "");
+ child_ctx->original_export_path.empty() ?
+ "" :
+ (std::string("ref ") + child_ctx->original_export_path).c_str());
}
else {
printf(" - %s (dup by %s%s) %s\n",
child_ctx->object->id.name + 2,
child_ctx->duplicator->id.name + 2,
child_ctx->weak_export ? ", weak" : "",
- child_ctx->original_export_path.size() ?
- (std::string("ref ") + child_ctx->original_export_path).c_str() :
- "");
+ child_ctx->original_export_path.empty() ?
+ "" :
+ (std::string("ref ") + child_ctx->original_export_path).c_str());
}
}
}