From a5fce46eddb3e42bf145017d2575746a6c899308 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 27 Aug 2018 13:17:32 +0200 Subject: [PATCH] clang-tidy -checks=-*,misc-string-compare --- .../NonUniformGrid/NonUniformGrid.cpp | 12 ++++---- src/blockforest/SetupBlockForest.cpp | 4 +-- src/core/logging/Initialization.cpp | 30 +++++++++---------- .../math/equation_system/EquationParser.cpp | 12 ++++---- src/core/math/equation_system/Variable.cpp | 2 +- src/geometry/mesh/TriangleMeshIO.cpp | 6 ++-- src/pe/Materials.cpp | 4 +-- src/vtk/Initialization.cpp | 4 +-- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/apps/benchmarks/NonUniformGrid/NonUniformGrid.cpp b/apps/benchmarks/NonUniformGrid/NonUniformGrid.cpp index 462bbeb41..5850db2e6 100644 --- a/apps/benchmarks/NonUniformGrid/NonUniformGrid.cpp +++ b/apps/benchmarks/NonUniformGrid/NonUniformGrid.cpp @@ -913,7 +913,7 @@ void run( const shared_ptr< Config > & config, const LatticeModel_T & latticeMod double refreshTime( 0.0 ); for( auto it = reducedTimeloopTiming->begin(); it != reducedTimeloopTiming->end(); ++it ) { - if( it->first.compare( refreshFunctorName ) == 0 ) + if( it->first == refreshFunctorName ) refreshTime += it->second.total(); else restTime += it->second.total(); @@ -927,15 +927,15 @@ void run( const shared_ptr< Config > & config, const LatticeModel_T & latticeMod for( auto it = reducedRefreshTiming->begin(); it != reducedRefreshTiming->end(); ++it ) { - if( it->first.compare( "block level determination" ) == 0 ) + if( it->first == "block level determination" ) blockLevelDeterminationTime += it->second.total(); - else if( it->first.compare( "block level determination (callback function)" ) == 0 ) + else if( it->first == "block level determination (callback function)" ) blockLevelDeterminationTime += it->second.total(); - else if( it->first.compare( "block structure update (includes data migration)" ) == 0 ) + else if( it->first == "block structure update (includes data migration)" ) dataMigrationTime += it->second.total(); - else if( it->first.compare( "phantom block redistribution (= load balancing)" ) == 0 ) + else if( it->first == "phantom block redistribution (= load balancing)" ) loadBalanceTime += it->second.total(); - else if( it->first.compare( "phantom forest creation" ) == 0 ) + else if( it->first == "phantom forest creation" ) phantomForestCreationTime += it->second.total(); } diff --git a/src/blockforest/SetupBlockForest.cpp b/src/blockforest/SetupBlockForest.cpp index 21876b83d..729dfdeb0 100644 --- a/src/blockforest/SetupBlockForest.cpp +++ b/src/blockforest/SetupBlockForest.cpp @@ -1248,7 +1248,7 @@ void SetupBlockForest::calculateProcessDistribution_Default( const uint_t WALBERLA_ABORT( "Load balancing failed: You must provide a per process memory limit greater than 0!\n" " (The memory limit you provided was \'" << memoryLimit << "\')" ); - if( sfcMethod.compare( "hilbert" ) != 0 && sfcMethod.compare( "morton" ) != 0 ) + if( sfcMethod != "hilbert" && sfcMethod != "morton" ) WALBERLA_ABORT( "Load balancing failed: SFC method \"" << sfcMethod << "\" unavailable " "(the only available methods are \"hilbert\" and \"morton\")" ) @@ -1262,7 +1262,7 @@ void SetupBlockForest::calculateProcessDistribution_Default( const uint_t std::vector< SetupBlock* > blocks; - if( sfcMethod.compare( "hilbert" ) == 0 ) + if( sfcMethod == "hilbert" ) getHilbertOrder( blocks ); else getMortonOrder( blocks ); diff --git a/src/core/logging/Initialization.cpp b/src/core/logging/Initialization.cpp index b80208178..cc50de9ce 100644 --- a/src/core/logging/Initialization.cpp +++ b/src/core/logging/Initialization.cpp @@ -142,15 +142,15 @@ void configureLogging( const Config::BlockHandle & loggingBlock ) std::string type = loggingBlock.getParameter< std::string >( "logLevel" ); boost::algorithm::to_lower( type ); - if( type.compare("warning") == 0 ){ + if( type == "warning" ){ logging::Logging::instance()->setLogLevel( logging::Logging::WARNING ); - } else if( type.compare("info") == 0 ){ + } else if( type == "info" ){ logging::Logging::instance()->setLogLevel( logging::Logging::INFO ); - } else if( type.compare("progress") == 0 ){ + } else if( type == "progress" ){ logging::Logging::instance()->setLogLevel( logging::Logging::PROGRESS ); - } else if( type.compare("detail") == 0 ){ + } else if( type == "detail" ){ logging::Logging::instance()->setLogLevel( logging::Logging::DETAIL ); - } else if( type.compare("tracing") == 0 ){ + } else if( type == "tracing" ){ logging::Logging::instance()->setLogLevel( logging::Logging::TRACING ); } else throw std::runtime_error("Error: Unknown parameter for 'logLevel'. Possible parameters are: warning|info|progress|detail|tracing"); @@ -161,15 +161,15 @@ void configureLogging( const Config::BlockHandle & loggingBlock ) std::string type = loggingBlock.getParameter< std::string >( "streamLogLevel" ); boost::algorithm::to_lower( type ); - if( type.compare("warning") == 0 ){ + if( type == "warning" ){ logging::Logging::instance()->setStreamLogLevel( logging::Logging::WARNING ); - } else if( type.compare("info") == 0 ){ + } else if( type == "info" ){ logging::Logging::instance()->setStreamLogLevel( logging::Logging::INFO ); - } else if( type.compare("progress") == 0 ){ + } else if( type == "progress" ){ logging::Logging::instance()->setStreamLogLevel( logging::Logging::PROGRESS ); - } else if( type.compare("detail") == 0 ){ + } else if( type == "detail" ){ logging::Logging::instance()->setStreamLogLevel( logging::Logging::DETAIL ); - } else if( type.compare("tracing") == 0 ){ + } else if( type == "tracing" ){ logging::Logging::instance()->setStreamLogLevel( logging::Logging::TRACING ); } else throw std::runtime_error("Error: Unknown parameter for 'streamLogLevel'. Possible parameters are: warning|info|progress|detail|tracing"); @@ -180,15 +180,15 @@ void configureLogging( const Config::BlockHandle & loggingBlock ) std::string type = loggingBlock.getParameter< std::string >( "fileLogLevel" ); boost::algorithm::to_lower( type ); - if( type.compare("warning") == 0 ){ + if( type == "warning" ){ logging::Logging::instance()->setFileLogLevel( logging::Logging::WARNING ); - } else if( type.compare("info") == 0 ){ + } else if( type == "info" ){ logging::Logging::instance()->setFileLogLevel( logging::Logging::INFO ); - } else if( type.compare("progress") == 0 ){ + } else if( type == "progress" ){ logging::Logging::instance()->setFileLogLevel( logging::Logging::PROGRESS ); - } else if( type.compare("detail") == 0 ){ + } else if( type == "detail" ){ logging::Logging::instance()->setFileLogLevel( logging::Logging::DETAIL ); - } else if( type.compare("tracing") == 0 ){ + } else if( type == "tracing" ){ logging::Logging::instance()->setFileLogLevel( logging::Logging::TRACING ); } else throw std::runtime_error("Error: Unknown parameter for 'fileLogLevel'. Possible parameters are: warning|info|progress|detail|tracing"); diff --git a/src/core/math/equation_system/EquationParser.cpp b/src/core/math/equation_system/EquationParser.cpp index 9f03f55e7..477bc2e03 100644 --- a/src/core/math/equation_system/EquationParser.cpp +++ b/src/core/math/equation_system/EquationParser.cpp @@ -148,21 +148,21 @@ NodePtr EquationParser::parseVariable( const std::string& str, size_t& index ) c //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool EquationParser::checkFunction( const std::string& str, size_t& index ) const { - return (str.substr(index, 4).compare("exp(" ) == 0) || - (str.substr(index, 3).compare("ln(" ) == 0) || - (str.substr(index, 5).compare("sqrt(" ) == 0); + return (str.substr(index, 4) == "exp(") || + (str.substr(index, 3) == "ln(") || + (str.substr(index, 5) == "sqrt("); } NodePtr EquationParser::parseFunction( const std::string& str, size_t& index ) const { OpFunction opFunc; - if ( str.substr(index, 4).compare("exp(") == 0 ){ + if ( str.substr(index, 4) == "exp(" ){ opFunc = OP_FUNC_EXP; index += 4; - } else if ( str.substr(index, 3).compare("ln(") == 0 ){ + } else if ( str.substr(index, 3) == "ln(" ){ opFunc = OP_FUNC_LN; index += 3; - } else if ( str.substr(index, 5).compare("sqrt(") == 0 ){ + } else if ( str.substr(index, 5) == "sqrt(" ){ opFunc = OP_FUNC_SQRT; index += 5; } else { diff --git a/src/core/math/equation_system/Variable.cpp b/src/core/math/equation_system/Variable.cpp index 04d9b7517..595b6292a 100644 --- a/src/core/math/equation_system/Variable.cpp +++ b/src/core/math/equation_system/Variable.cpp @@ -40,7 +40,7 @@ namespace math { } bool Var::operator==( const Var& var) const { - return name_.compare( var.name_ ) == 0; + return name_ == var.name_; } std::ostream& operator<<( std::ostream& os, const Var & var ){ diff --git a/src/geometry/mesh/TriangleMeshIO.cpp b/src/geometry/mesh/TriangleMeshIO.cpp index a880bff03..60b737232 100644 --- a/src/geometry/mesh/TriangleMeshIO.cpp +++ b/src/geometry/mesh/TriangleMeshIO.cpp @@ -363,11 +363,11 @@ namespace geometry { for( size_t i=1; i<splitVec.size(); ++i ) { boost::trim(splitVec[i]); - if( splitVec[i].compare("vertex_vectors") == 0 ) { + if( splitVec[i] == "vertex_vectors" ) { state = VERTEX; - } else if ( splitVec[i].compare("normal_vectors") == 0 ) { + } else if ( splitVec[i] == "normal_vectors" ) { state = NORMAL; - } else if ( splitVec[i].compare("face_indices") == 0 ) { + } else if ( splitVec[i] == "face_indices" ) { state = FACE; } else { //std::cerr << "Unknown section in povray file: " << splitVec[i] << "\n"; diff --git a/src/pe/Materials.cpp b/src/pe/Materials.cpp index 1f82e7fa6..baa82126a 100644 --- a/src/pe/Materials.cpp +++ b/src/pe/Materials.cpp @@ -168,7 +168,7 @@ MaterialID createMaterial( const std::string& name, real_t density, real_t cor, Materials::const_iterator begin( M::materials_.begin() ); Materials::const_iterator end ( M::materials_.end() ); for( ; begin!=end; ++begin ) { - if( begin->getName().compare( name ) == 0 ) + if( begin->getName() == name ) throw std::invalid_argument( "Material of that name already exists!" ); } @@ -280,7 +280,7 @@ MaterialID createMaterial( real_t density, real_t cor, real_t csf, real_t cdf, r MaterialID Material::find( const std::string& name ) { for( Material::SizeType i=0; i<Material::materials_.size(); ++i ) { - if( Material::materials_[i].getName().compare( name ) == 0 ) { + if( Material::materials_[i].getName() == name ) { return i; } } diff --git a/src/vtk/Initialization.cpp b/src/vtk/Initialization.cpp index bac98bdb9..2ad2e82de 100644 --- a/src/vtk/Initialization.cpp +++ b/src/vtk/Initialization.cpp @@ -295,7 +295,7 @@ void initializeVTKOutput( std::map< std::string, SelectableOutputFunction > & ou { for( auto inclusionFilterId = inclusionFiltersBlock.begin(); inclusionFilterId != inclusionFiltersBlock.end(); ++inclusionFilterId ) { - if( inclusionFilterId->first.compare( "combine" ) == 0 ) + if( inclusionFilterId->first == "combine" ) { std::vector< std::string > filterList = splitList( inclusionFilterId->second ); ChainedFilter combine; @@ -323,7 +323,7 @@ void initializeVTKOutput( std::map< std::string, SelectableOutputFunction > & ou { for( auto exclusionFilterId = exclusionFiltersBlock.begin(); exclusionFilterId != exclusionFiltersBlock.end(); ++exclusionFilterId ) { - if( exclusionFilterId->first.compare( "combine" ) == 0 ) + if( exclusionFilterId->first == "combine" ) { std::vector< std::string > filterList = splitList( exclusionFilterId->second ); ChainedFilter combine; -- GitLab