diff --git a/src/TNL/Benchmarks/Utils.h b/src/TNL/Benchmarks/Utils.h index fe57c891eefecf8618310076f09a6a0307e109fe..b6b3b4263acf1595591e814c7a931a81bdce819a 100644 --- a/src/TNL/Benchmarks/Utils.h +++ b/src/TNL/Benchmarks/Utils.h @@ -158,7 +158,7 @@ writeMapAsJson( const std::map< std::string, std::string >& data, std::string fi { namespace fs = std::experimental::filesystem; - if( newExtension != "" ) { + if( ! newExtension.empty() ) { const fs::path oldPath = filename; const fs::path newPath = oldPath.parent_path() / ( oldPath.stem().string() + newExtension ); filename = newPath; diff --git a/src/TNL/Config/ConfigEntry.h b/src/TNL/Config/ConfigEntry.h index b589e61892a163ce1fc48192aad825c14a9bddc1..f7f777b228ff6fbb916e937155dedcc604109c1c 100644 --- a/src/TNL/Config/ConfigEntry.h +++ b/src/TNL/Config/ConfigEntry.h @@ -59,9 +59,7 @@ public: bool hasEnumValues() const override { - if( enumValues.size() > 0 ) - return true; - return false; + return ! enumValues.empty(); } void diff --git a/src/TNL/Config/parseCommandLine.h b/src/TNL/Config/parseCommandLine.h index db48c08fb3ca4ba68697a22ef3e4086ba36faa7d..cc41fddc7e41e8c5bb66885882554a77eedd0ce6 100644 --- a/src/TNL/Config/parseCommandLine.h +++ b/src/TNL/Config/parseCommandLine.h @@ -153,7 +153,7 @@ checkMissingEntries( const ConfigDescription& config, if( entryBase->isRequired() && ! parameters.checkParameter( entry_name ) ) missingParameters.push_back( entry_name ); } - if( missingParameters.size() > 0 ) { + if( ! missingParameters.empty() ) { std::cerr << "Some mandatory parameters are misssing. They are listed at the end." << std::endl; if( printUsage ) Config::printUsage( config, programName ); @@ -256,7 +256,7 @@ parseCommandLine( int argc, if( value.empty() ) throw Exceptions::ConfigError( "Missing value for the parameter " + option + "." ); const std::vector< String > parsedEntryType = entryType.split(); - if( parsedEntryType.size() == 0 ) + if( parsedEntryType.empty() ) throw Exceptions::ConfigError( "Internal error: Unknown config entry type " + entryType + "." ); if( parsedEntryType[ 0 ] == "list" ) { std::vector< bool > bool_list; @@ -298,15 +298,15 @@ parseCommandLine( int argc, // this will not happen if all entry types are handled above throw std::runtime_error( "Function parseCommandLine encountered unsupported entry type: " + entryType ); } - if( bool_list.size() ) + if( ! bool_list.empty() ) parameters.addParameter< std::vector< bool > >( option, bool_list ); - if( integer_list.size() ) + if( ! integer_list.empty() ) parameters.addParameter< std::vector< Integer > >( option, integer_list ); - if( unsigned_integer_list.size() ) + if( ! unsigned_integer_list.empty() ) parameters.addParameter< std::vector< UnsignedInteger > >( option, unsigned_integer_list ); - if( real_list.size() ) + if( ! real_list.empty() ) parameters.addParameter< std::vector< double > >( option, real_list ); - if( string_list.size() ) + if( ! string_list.empty() ) parameters.addParameter< std::vector< std::string > >( option, string_list ); } else { diff --git a/src/TNL/Meshes/Readers/MeshReader.h b/src/TNL/Meshes/Readers/MeshReader.h index b07168c216864963b9fe065f8adb813de5359614..556a363da1e41ce54d69aeb22bdeadde0fa40367 100644 --- a/src/TNL/Meshes/Readers/MeshReader.h +++ b/src/TNL/Meshes/Readers/MeshReader.h @@ -92,7 +92,7 @@ public: loadMesh( MeshType& mesh ) { // check that detectMesh has been called - if( meshType == "" ) + if( meshType.empty() ) detectMesh(); // check if we have a grid @@ -151,7 +151,7 @@ public: loadMesh( MeshType& mesh ) { // check that detectMesh has been called - if( meshType == "" ) + if( meshType.empty() ) detectMesh(); // check if we have an unstructured mesh diff --git a/src/TNL/Meshes/Readers/PVTIReader.h b/src/TNL/Meshes/Readers/PVTIReader.h index 47178e227b1918c7b4218c33c8b28588a6b26309..e8c0c7eaf7638608015d7671998ffa72ea4b8b28 100644 --- a/src/TNL/Meshes/Readers/PVTIReader.h +++ b/src/TNL/Meshes/Readers/PVTIReader.h @@ -125,7 +125,7 @@ class PVTIReader : public XMLVTK const XMLElement* piece = getChildSafe( datasetElement, "Piece" ); while( piece ) { const std::string source = getAttributeString( piece, "Source" ); - if( source != "" ) { + if( ! source.empty() ) { pieceSources.push_back( getSourcePath( source ) ); } else @@ -133,7 +133,7 @@ class PVTIReader : public XMLVTK // find next piece = piece->NextSiblingElement( "Piece" ); } - if( pieceSources.size() == 0 ) + if( pieceSources.empty() ) throw MeshReaderError( "PVTIReader", "the file does not contain any <Piece> element." ); // check that the number of pieces matches the number of MPI ranks @@ -210,7 +210,7 @@ public: loadMesh( MeshType& mesh ) { // check that detectMesh has been called - if( meshType == "" ) + if( meshType.empty() ) detectMesh(); // check if we have a distributed grid diff --git a/src/TNL/Meshes/Readers/PVTUReader.h b/src/TNL/Meshes/Readers/PVTUReader.h index 330045d929a9cb67764d3df9162071afbafa342d..293d62810e4deb8bd8159599984af17d5f3a3a5b 100644 --- a/src/TNL/Meshes/Readers/PVTUReader.h +++ b/src/TNL/Meshes/Readers/PVTUReader.h @@ -53,7 +53,7 @@ class PVTUReader : public XMLVTK const XMLElement* piece = getChildSafe( datasetElement, "Piece" ); while( piece ) { const std::string source = getAttributeString( piece, "Source" ); - if( source != "" ) { + if( ! source.empty() ) { pieceSources.push_back( getSourcePath( source ) ); } else @@ -61,7 +61,7 @@ class PVTUReader : public XMLVTK // find next piece = piece->NextSiblingElement( "Piece" ); } - if( pieceSources.size() == 0 ) + if( pieceSources.empty() ) throw MeshReaderError( "PVTUReader", "the file does not contain any <Piece> element." ); // check that the number of pieces matches the number of MPI ranks @@ -144,7 +144,7 @@ public: loadMesh( MeshType& mesh ) { // check that detectMesh has been called - if( meshType == "" ) + if( meshType.empty() ) detectMesh(); // check if we have a distributed unstructured mesh diff --git a/src/TNL/Meshes/Readers/XMLVTK.h b/src/TNL/Meshes/Readers/XMLVTK.h index 10e9be0a4c1702368406736d8bcc183fd5ca8112..b7cd96e8af19374e8b395969a44eae78ecb59072 100644 --- a/src/TNL/Meshes/Readers/XMLVTK.h +++ b/src/TNL/Meshes/Readers/XMLVTK.h @@ -198,7 +198,7 @@ protected: while( *block != '\0' && std::isspace( *block ) ) ++block; - if( compressor == "" ) { + if( compressor.empty() ) { std::size_t data_size = 0; const T* data_ptr = nullptr; std::pair< std::size_t, std::unique_ptr< std::uint8_t[] > > decoded_data = @@ -393,7 +393,7 @@ public: compressor = getAttributeString( elem, "compressor", "<none>" ); if( compressor == "<none>" ) compressor = ""; - if( compressor != "" && compressor != "vtkZLibDataCompressor" ) + if( ! compressor.empty() && compressor != "vtkZLibDataCompressor" ) throw MeshReaderError( "XMLVTK", "unsupported compressor type: " + compressor + " (only vtkZLibDataCompressor is supported)" ); diff --git a/src/TNL/Object.hpp b/src/TNL/Object.hpp index 7e0d2f318f929d0b4d658fbb990288e473c64218..c9f7f4e96da61b154500ea6d5cab1585d8e63699 100644 --- a/src/TNL/Object.hpp +++ b/src/TNL/Object.hpp @@ -113,7 +113,7 @@ parseObjectType( const String& objectType ) templateBrackets++; if( ! templateBrackets ) { if( objectType[ i ] == ',' || objectType[ i ] == '>' ) { - if( buffer != "" ) { + if( ! buffer.empty() ) { parsedObjectType.push_back( buffer.strip( ' ' ) ); buffer.clear(); } diff --git a/src/TNL/Solvers/IterativeSolverMonitor.hpp b/src/TNL/Solvers/IterativeSolverMonitor.hpp index d0ca7e49dc601354537dd68938de439c046a0ea9..dff01e472b13186fc6199a64456df092bd6a538b 100644 --- a/src/TNL/Solvers/IterativeSolverMonitor.hpp +++ b/src/TNL/Solvers/IterativeSolverMonitor.hpp @@ -149,7 +149,7 @@ IterativeSolverMonitor< Real, Index >::refresh() } const std::string displayed_stage = ( saved ) ? saved_stage : stage; - if( displayed_stage.length() && free > 5 ) { + if( ! displayed_stage.empty() && free > 5 ) { if( (int) displayed_stage.length() <= free - 2 ) { std::cout << " " << displayed_stage; free -= ( 2 + displayed_stage.length() ); diff --git a/src/TNL/String.hpp b/src/TNL/String.hpp index 8da511f14b7ef4f5517a85fe8124e3e2a95380bd..5c46b55394feb561e08b5d73ec1d4cc51bdd4ba3 100644 --- a/src/TNL/String.hpp +++ b/src/TNL/String.hpp @@ -186,7 +186,7 @@ String::operator!=( const String& str ) const inline String::operator bool() const { - return getLength(); + return ! empty(); } inline bool @@ -239,14 +239,14 @@ String::split( char separator, SplitSkip skip ) const String s; for( int i = 0; i < this->getLength(); i++ ) { if( ( *this )[ i ] == separator ) { - if( skip != SplitSkip::SkipEmpty || s != "" ) + if( skip != SplitSkip::SkipEmpty || ! s.empty() ) parts.push_back( s ); s = ""; } else s += ( *this )[ i ]; } - if( skip != SplitSkip::SkipEmpty || s != "" ) + if( skip != SplitSkip::SkipEmpty || ! s.empty() ) parts.push_back( s ); return parts; } diff --git a/src/TNL/SystemInfo.hpp b/src/TNL/SystemInfo.hpp index c95e61d3f16acb0a2ca3766e65d6d2ae0516cdc6..52a029cf812a96a3b79a39cde8400e30fff9e5e4 100644 --- a/src/TNL/SystemInfo.hpp +++ b/src/TNL/SystemInfo.hpp @@ -104,7 +104,7 @@ inline String SystemInfo::getCPUModelName( int cpu_id ) { static String CPUModelName; - if( CPUModelName == "" ) { + if( CPUModelName.empty() ) { CPUInfo info = parseCPUInfo(); CPUModelName = info.CPUModelName; }