Apply various performance fixes from clang-tidy

This commit is contained in:
Aaron Gokaslan
2021-06-22 12:27:15 -04:00
parent 43a5c6c8e3
commit 94c3abd841
37 changed files with 131 additions and 143 deletions
+11 -12
View File
@@ -106,14 +106,13 @@ void ExportScenePbrt (
} // end of namespace Assimp
// Constructor
PbrtExporter::PbrtExporter (
const aiScene* pScene, IOSystem* pIOSystem,
const std::string path, const std::string file)
: mScene(pScene),
mIOSystem(pIOSystem),
mPath(path),
mFile(file)
{
PbrtExporter::PbrtExporter(
const aiScene *pScene, IOSystem *pIOSystem,
const std::string &path, const std::string &file) :
mScene(pScene),
mIOSystem(pIOSystem),
mPath(path),
mFile(file) {
// Export embedded textures.
if (mScene->mNumTextures > 0)
if (!mIOSystem->CreateDirectory("textures"))
@@ -210,12 +209,12 @@ void PbrtExporter::WriteMetaData() {
aiString* value =
static_cast<aiString*>(pMetaData->mValues[i].mData);
std::string svalue = value->C_Str();
std::size_t found = svalue.find_first_of("\n");
std::size_t found = svalue.find_first_of('\n');
mOutput << "\n";
while (found != std::string::npos) {
mOutput << "# " << svalue.substr(0, found) << "\n";
svalue = svalue.substr(found + 1);
found = svalue.find_first_of("\n");
found = svalue.find_first_of('\n');
}
mOutput << "# " << svalue << "\n";
break;
@@ -596,8 +595,8 @@ void PbrtExporter::WriteMaterial(int m) {
}
mOutput << "\n";
auto White = [](aiColor3D c) { return c.r == 1 && c.g == 1 && c.b == 1; };
auto Black = [](aiColor3D c) { return c.r == 0 && c.g == 0 && c.b == 0; };
auto White = [](const aiColor3D &c) { return c.r == 1 && c.g == 1 && c.b == 1; };
auto Black = [](const aiColor3D &c) { return c.r == 0 && c.g == 0 && c.b == 0; };
aiColor3D diffuse, specular, transparency;
bool constantDiffuse = (material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse) == AI_SUCCESS &&