From ff828a85d0deb8d7a3e9fea2595f8441ee3a6e01 Mon Sep 17 00:00:00 2001 From: lucafedeli88 Date: Wed, 4 Oct 2023 05:24:26 +0200 Subject: [PATCH 01/15] add all the performance-* clang-tidy checks --- .clang-tidy | 2 +- examples/10_streaming_read.cpp | 4 +- examples/8_benchmark_parallel.cpp | 4 +- include/openPMD/Dataset.hpp | 4 +- include/openPMD/Datatype.hpp | 2 +- include/openPMD/Error.hpp | 4 +- include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp | 14 +++---- .../openPMD/IO/AbstractIOHandlerHelper.hpp | 6 +-- include/openPMD/IO/AbstractIOHandlerImpl.hpp | 2 +- include/openPMD/IO/HDF5/HDF5Auxiliary.hpp | 2 +- include/openPMD/IO/HDF5/HDF5IOHandler.hpp | 2 +- .../openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp | 4 +- include/openPMD/IO/InvalidatableFile.hpp | 4 +- include/openPMD/IO/JSON/JSONIOHandler.hpp | 4 +- include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp | 20 +++++----- include/openPMD/Iteration.hpp | 2 +- include/openPMD/ReadIterations.hpp | 2 +- include/openPMD/Series.hpp | 6 +-- include/openPMD/ThrowError.hpp | 2 +- include/openPMD/cli/ls.hpp | 4 +- src/Dataset.cpp | 4 +- src/Datatype.cpp | 2 +- src/Error.cpp | 8 ++-- src/IO/ADIOS/ADIOS2IOHandler.cpp | 32 ++++++++-------- src/IO/AbstractIOHandlerHelper.cpp | 8 ++-- src/IO/AbstractIOHandlerImpl.cpp | 2 +- src/IO/HDF5/HDF5Auxiliary.cpp | 2 +- src/IO/HDF5/HDF5IOHandler.cpp | 6 +-- src/IO/HDF5/ParallelHDF5IOHandler.cpp | 12 +++--- src/IO/InvalidatableFile.cpp | 4 +- src/IO/JSON/JSONIOHandler.cpp | 6 +-- src/IO/JSON/JSONIOHandlerImpl.cpp | 20 +++++----- src/Iteration.cpp | 2 +- src/ReadIterations.cpp | 4 +- src/Series.cpp | 10 ++--- src/WriteIterations.cpp | 4 +- src/auxiliary/Filesystem.cpp | 3 +- src/auxiliary/JSON.cpp | 4 +- src/backend/Attributable.cpp | 4 +- src/backend/Writable.cpp | 2 +- src/binding/python/Attributable.cpp | 30 +++++++-------- src/binding/python/ChunkInfo.cpp | 2 +- src/binding/python/Dataset.cpp | 8 ++-- src/binding/python/Datatype.cpp | 2 +- src/binding/python/PatchRecordComponent.cpp | 2 +- src/binding/python/RecordComponent.cpp | 4 +- src/cli/ls.cpp | 1 + src/version.cpp | 6 +-- test/AuxiliaryTest.cpp | 6 +-- test/ParallelIOTest.cpp | 18 ++++----- test/SerialIOTest.cpp | 38 +++++++++---------- 51 files changed, 176 insertions(+), 174 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 7998697f29..034a863660 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,5 +2,5 @@ # FIXME: all performance-* reports # FIXME: all cert-* reports # FIXME: all bugprone-* reports -Checks: -*,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-parent-virtual-call,-bugprone-narrowing-conversions,-bugprone-exception-escape,-bugprone-string-literal-with-embedded-nul,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,performance-for-range-copy,modernize-*,-modernize-use-trailing-return-type,-modernize-use-bool-literals,-modernize-avoid-c-arrays,-modernize-use-auto,-modernize-return-braced-init-list +Checks: -*,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-parent-virtual-call,-bugprone-narrowing-conversions,-bugprone-exception-escape,-bugprone-string-literal-with-embedded-nul,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,performance-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-bool-literals,-modernize-avoid-c-arrays,-modernize-use-auto,-modernize-return-braced-init-list HeaderFilterRegex: '((^(?!\/share\/openPMD\/).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)' diff --git a/examples/10_streaming_read.cpp b/examples/10_streaming_read.cpp index 6e6aba1fd9..99da2c5a5c 100644 --- a/examples/10_streaming_read.cpp +++ b/examples/10_streaming_read.cpp @@ -46,7 +46,7 @@ int main() for (size_t i = 0; i < 3; ++i) { - std::string dim = dimensions[i]; + std::string const &dim = dimensions[i]; RecordComponent rc = electronPositions[dim]; loadedChunks[i] = rc.loadChunk( Offset(rc.getDimensionality(), 0), rc.getExtent()); @@ -60,7 +60,7 @@ int main() for (size_t i = 0; i < 3; ++i) { - std::string dim = dimensions[i]; + std::string const &dim = dimensions[i]; Extent const &extent = extents[i]; std::cout << "\ndim: " << dim << "\n" << std::endl; auto chunk = loadedChunks[i]; diff --git a/examples/8_benchmark_parallel.cpp b/examples/8_benchmark_parallel.cpp index 5adf2512ff..c8c1db88f8 100644 --- a/examples/8_benchmark_parallel.cpp +++ b/examples/8_benchmark_parallel.cpp @@ -12,7 +12,7 @@ #include #if openPMD_HAVE_MPI -inline void print_help(std::string const program_name) +inline void print_help(std::string const &program_name) { std::cout << "Usage: " << program_name << "\n"; std::cout << "Run a simple parallel write and read benchmark.\n\n"; @@ -27,7 +27,7 @@ inline void print_help(std::string const program_name) std::cout << " " << program_name << " # for a strong scaling\n"; } -inline void print_version(std::string const program_name) +inline void print_version(std::string const &program_name) { std::cout << program_name << " (openPMD-api) " << openPMD::getVersion() << "\n"; diff --git a/include/openPMD/Dataset.hpp b/include/openPMD/Dataset.hpp index 8757a3cf0a..9b9540da4d 100644 --- a/include/openPMD/Dataset.hpp +++ b/include/openPMD/Dataset.hpp @@ -37,7 +37,7 @@ class Dataset friend class RecordComponent; public: - Dataset(Datatype, Extent, std::string options = "{}"); + Dataset(Datatype, Extent const&, std::string options = "{}"); /** * @brief Constructor that sets the datatype to undefined. @@ -45,7 +45,7 @@ class Dataset * Helpful for resizing datasets, since datatypes need not be given twice. * */ - Dataset(Extent); + Dataset(Extent const&); Dataset &extend(Extent newExtent); diff --git a/include/openPMD/Datatype.hpp b/include/openPMD/Datatype.hpp index 05d0ddefbb..6b368ee523 100644 --- a/include/openPMD/Datatype.hpp +++ b/include/openPMD/Datatype.hpp @@ -739,7 +739,7 @@ Datatype toVectorType(Datatype dt); std::string datatypeToString(Datatype dt); -Datatype stringToDatatype(std::string s); +Datatype stringToDatatype(const std::string& s); void warnWrongDtype(std::string const &key, Datatype store, Datatype request); diff --git a/include/openPMD/Error.hpp b/include/openPMD/Error.hpp index c50e2918b6..8eca11ceda 100644 --- a/include/openPMD/Error.hpp +++ b/include/openPMD/Error.hpp @@ -50,7 +50,7 @@ namespace error { public: std::string backend; - OperationUnsupportedInBackend(std::string backend_in, std::string what); + OperationUnsupportedInBackend(std::string backend_in, const std::string& what); }; /** @@ -62,7 +62,7 @@ namespace error class WrongAPIUsage : public Error { public: - WrongAPIUsage(std::string what); + WrongAPIUsage(const std::string& what); }; class BackendConfigSchema : public Error diff --git a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp index 86afffbbdf..2e70e76cf0 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp @@ -391,9 +391,9 @@ class ADIOS2IOHandlerImpl ThrowError }; - detail::BufferedActions &getFileData(InvalidatableFile file, IfFileNotOpen); + detail::BufferedActions &getFileData(InvalidatableFile const &file, IfFileNotOpen); - void dropFileData(InvalidatableFile file); + void dropFileData(InvalidatableFile const &file); /* * Prepare a variable that already exists for an IO @@ -465,7 +465,7 @@ namespace detail ADIOS2IOHandlerImpl &, adios2::IO &IO, std::string name, - std::shared_ptr resource); + std::shared_ptr const &resource); template static Datatype call(Params &&...); @@ -488,8 +488,8 @@ namespace detail template static void call( ADIOS2IOHandlerImpl *impl, - InvalidatableFile, - const std::string &varName, + InvalidatableFile const &, + std::string const &varName, Parameter ¶meters); static constexpr char const *errorMsg = "ADIOS2: openDataset()"; @@ -1195,7 +1195,7 @@ class ADIOS2IOHandler : public AbstractIOHandler #if openPMD_HAVE_MPI ADIOS2IOHandler( - std::string path, + std::string const &path, Access, MPI_Comm, json::TracingJSON options, @@ -1205,7 +1205,7 @@ class ADIOS2IOHandler : public AbstractIOHandler #endif ADIOS2IOHandler( - std::string path, + std::string const &path, Access, json::TracingJSON options, std::string engineType, diff --git a/include/openPMD/IO/AbstractIOHandlerHelper.hpp b/include/openPMD/IO/AbstractIOHandlerHelper.hpp index a5ce7a39be..0d0b19f089 100644 --- a/include/openPMD/IO/AbstractIOHandlerHelper.hpp +++ b/include/openPMD/IO/AbstractIOHandlerHelper.hpp @@ -47,7 +47,7 @@ namespace openPMD */ template std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension, @@ -74,7 +74,7 @@ std::unique_ptr createIOHandler( */ template std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension, @@ -83,7 +83,7 @@ std::unique_ptr createIOHandler( // version without configuration to use in AuxiliaryTest std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension); diff --git a/include/openPMD/IO/AbstractIOHandlerImpl.hpp b/include/openPMD/IO/AbstractIOHandlerImpl.hpp index 8d13f3feb8..48b8efb02b 100644 --- a/include/openPMD/IO/AbstractIOHandlerImpl.hpp +++ b/include/openPMD/IO/AbstractIOHandlerImpl.hpp @@ -391,7 +391,7 @@ class AbstractIOHandlerImpl * into the current writable) should be enough for all backends. */ void - keepSynchronous(Writable *, Parameter param); + keepSynchronous(Writable *, Parameter const ¶m); /** Notify the backend that the Writable has been / will be deallocated. * diff --git a/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp b/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp index da7ff2f68f..dc040f7053 100644 --- a/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp +++ b/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp @@ -62,5 +62,5 @@ std::string concrete_h5_file_position(Writable *w); * @return array for resulting chunk dimensions */ std::vector -getOptimalChunkDims(std::vector const dims, size_t const typeSize); +getOptimalChunkDims(std::vector const &dims, size_t const typeSize); } // namespace openPMD diff --git a/include/openPMD/IO/HDF5/HDF5IOHandler.hpp b/include/openPMD/IO/HDF5/HDF5IOHandler.hpp index e81996b389..da335de758 100644 --- a/include/openPMD/IO/HDF5/HDF5IOHandler.hpp +++ b/include/openPMD/IO/HDF5/HDF5IOHandler.hpp @@ -34,7 +34,7 @@ class HDF5IOHandlerImpl; class HDF5IOHandler : public AbstractIOHandler { public: - HDF5IOHandler(std::string path, Access, json::TracingJSON config); + HDF5IOHandler(std::string const &path, Access, json::TracingJSON config); ~HDF5IOHandler() override; std::string backendName() const override diff --git a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp index 18d43c93ab..26d6ca8673 100644 --- a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp +++ b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp @@ -37,9 +37,9 @@ class ParallelHDF5IOHandler : public AbstractIOHandler public: #if openPMD_HAVE_MPI ParallelHDF5IOHandler( - std::string path, Access, MPI_Comm, json::TracingJSON config); + std::string const &path, Access, MPI_Comm, json::TracingJSON config); #else - ParallelHDF5IOHandler(std::string path, Access, json::TracingJSON config); + ParallelHDF5IOHandler(std::string const &path, Access, json::TracingJSON config); #endif ~ParallelHDF5IOHandler() override; diff --git a/include/openPMD/IO/InvalidatableFile.hpp b/include/openPMD/IO/InvalidatableFile.hpp index 31c9fd3fcc..9a6d3fab3d 100644 --- a/include/openPMD/IO/InvalidatableFile.hpp +++ b/include/openPMD/IO/InvalidatableFile.hpp @@ -42,7 +42,7 @@ namespace openPMD */ struct InvalidatableFile { - explicit InvalidatableFile(std::string s); + explicit InvalidatableFile(std::string const &s); InvalidatableFile() = default; @@ -60,7 +60,7 @@ struct InvalidatableFile bool valid() const; - InvalidatableFile &operator=(std::string s); + InvalidatableFile &operator=(std::string const &s); bool operator==(InvalidatableFile const &f) const; diff --git a/include/openPMD/IO/JSON/JSONIOHandler.hpp b/include/openPMD/IO/JSON/JSONIOHandler.hpp index 452098137e..923c032853 100644 --- a/include/openPMD/IO/JSON/JSONIOHandler.hpp +++ b/include/openPMD/IO/JSON/JSONIOHandler.hpp @@ -30,9 +30,9 @@ class JSONIOHandler : public AbstractIOHandler { public: JSONIOHandler( - std::string path, + std::string const &path, Access at, - openPMD::json::TracingJSON config, + openPMD::json::TracingJSON const &config, JSONIOHandlerImpl::FileFormat, std::string originalExtension); diff --git a/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp b/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp index c935647665..07b25b030e 100644 --- a/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp +++ b/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp @@ -84,7 +84,7 @@ struct File return fileState->valid; } - File &operator=(std::string s) + File &operator=(std::string const &s) { if (fileState) { @@ -163,7 +163,7 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl explicit JSONIOHandlerImpl( AbstractIOHandler *, - openPMD::json::TracingJSON config, + openPMD::json::TracingJSON const &config, FileFormat, std::string originalExtension); @@ -259,10 +259,10 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl // else null. first tuple element needs to be a pointer, since the casted // streams are references only. std::tuple, std::istream *, std::ostream *> - getFilehandle(File, Access access); + getFilehandle(File const &, Access access); // full operating system path of the given file - std::string fullPath(File); + std::string fullPath(File const &); std::string fullPath(std::string const &); @@ -304,7 +304,7 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl // make sure that the given path exists in proper form in // the passed json value - static void ensurePath(nlohmann::json *json, std::string path); + static void ensurePath(nlohmann::json *json, std::string const &path); // In order not to insert the same file name into the data structures // with a new pointer (e.g. when reopening), search for a possibly @@ -312,24 +312,24 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl // The bool is true iff the pointer has been newly-created. // The iterator is an iterator for m_files std::tuple::iterator, bool> - getPossiblyExisting(std::string file); + getPossiblyExisting(std::string const &file); // get the json value representing the whole file, possibly reading // from disk - std::shared_ptr obtainJsonContents(File); + std::shared_ptr obtainJsonContents(File const &); // get the json value at the writable's fileposition nlohmann::json &obtainJsonContents(Writable *writable); // write to disk the json contents associated with the file // remove from m_dirty if unsetDirty == true - void putJsonContents(File, bool unsetDirty = true); + void putJsonContents(File const &, bool unsetDirty = true); // figure out the file position of the writable // (preferring the parent's file position) and extend it // by extend. return the modified file position. std::shared_ptr - setAndGetFilePosition(Writable *, std::string extend); + setAndGetFilePosition(Writable *, std::string const &extend); // figure out the file position of the writable // (preferring the parent's file position) @@ -345,7 +345,7 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl void associateWithFile(Writable *writable, File); // need to check the name too in order to exclude "attributes" key - static bool isGroup(nlohmann::json::const_iterator it); + static bool isGroup(nlohmann::json::const_iterator const &it); static bool isDataset(nlohmann::json const &j); diff --git a/include/openPMD/Iteration.hpp b/include/openPMD/Iteration.hpp index fd1f14cd00..e340712658 100644 --- a/include/openPMD/Iteration.hpp +++ b/include/openPMD/Iteration.hpp @@ -284,7 +284,7 @@ class Iteration : public Attributable */ void reread(std::string const &path); void readFileBased( - std::string filePath, std::string const &groupPath, bool beginStep); + std::string const &filePath, std::string const &groupPath, bool beginStep); void readGorVBased(std::string const &groupPath, bool beginStep); void read_impl(std::string const &groupPath); void readMeshes(std::string const &meshesPath); diff --git a/include/openPMD/ReadIterations.hpp b/include/openPMD/ReadIterations.hpp index a7cf0d18b5..cc5817984f 100644 --- a/include/openPMD/ReadIterations.hpp +++ b/include/openPMD/ReadIterations.hpp @@ -77,7 +77,7 @@ class SeriesIterator explicit SeriesIterator(); SeriesIterator( - Series, std::optional parsePreference); + Series const&, std::optional const &parsePreference); SeriesIterator &operator++(); diff --git a/include/openPMD/Series.hpp b/include/openPMD/Series.hpp index 1d99b54a84..be74a6ff18 100644 --- a/include/openPMD/Series.hpp +++ b/include/openPMD/Series.hpp @@ -637,12 +637,12 @@ OPENPMD_private std::future flush_impl( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler = true); void flushFileBased( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler = true); /* * Group-based and variable-based iteration layouts share a lot of logic @@ -654,7 +654,7 @@ OPENPMD_private void flushGorVBased( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler = true); void flushMeshesPath(); void flushParticlesPath(); diff --git a/include/openPMD/ThrowError.hpp b/include/openPMD/ThrowError.hpp index f2695f7ae0..52286782b2 100644 --- a/include/openPMD/ThrowError.hpp +++ b/include/openPMD/ThrowError.hpp @@ -51,7 +51,7 @@ enum class Reason throwBackendConfigSchema(std::vector jsonPath, std::string what); [[noreturn]] OPENPMDAPI_EXPORT void -throwOperationUnsupportedInBackend(std::string backend, std::string what); +throwOperationUnsupportedInBackend(std::string backend, std::string const &what); [[noreturn]] OPENPMDAPI_EXPORT void throwReadError( AffectedObject affectedObject, diff --git a/include/openPMD/cli/ls.hpp b/include/openPMD/cli/ls.hpp index 1d2313e250..c56da30254 100644 --- a/include/openPMD/cli/ls.hpp +++ b/include/openPMD/cli/ls.hpp @@ -34,7 +34,7 @@ namespace cli { namespace ls { - inline void print_help(std::string const program_name) + inline void print_help(std::string const &program_name) { std::cout << "Usage: " << program_name << " openPMD-series\n"; std::cout << "List information about an openPMD data series.\n\n"; @@ -54,7 +54,7 @@ namespace cli << " ./samples/serial_patch.bp\n"; } - inline void print_version(std::string const program_name) + inline void print_version(std::string const & program_name) { std::cout << program_name << " (openPMD-api) " << getVersion() << "\n"; diff --git a/src/Dataset.cpp b/src/Dataset.cpp index 587598db63..7621564b42 100644 --- a/src/Dataset.cpp +++ b/src/Dataset.cpp @@ -25,14 +25,14 @@ namespace openPMD { -Dataset::Dataset(Datatype d, Extent e, std::string options_in) +Dataset::Dataset(Datatype d, const Extent& e, std::string options_in) : extent{e} , dtype{d} , rank{static_cast(e.size())} , options{std::move(options_in)} {} -Dataset::Dataset(Extent e) : Dataset(Datatype::UNDEFINED, std::move(e)) +Dataset::Dataset(Extent const &e) : Dataset(Datatype::UNDEFINED, e) {} Dataset &Dataset::extend(Extent newExtents) diff --git a/src/Datatype.cpp b/src/Datatype.cpp index f0f26f7ae9..09f9e45f34 100644 --- a/src/Datatype.cpp +++ b/src/Datatype.cpp @@ -163,7 +163,7 @@ std::ostream &operator<<(std::ostream &os, openPMD::Datatype const &d) return os; } -Datatype stringToDatatype(std::string s) +Datatype stringToDatatype(const std::string& s) { static std::unordered_map m{ {"CHAR", Datatype::CHAR}, diff --git a/src/Error.cpp b/src/Error.cpp index a8e83338ed..eb08588b84 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -12,19 +12,19 @@ const char *Error::what() const noexcept namespace error { OperationUnsupportedInBackend::OperationUnsupportedInBackend( - std::string backend_in, std::string what) + std::string backend_in, const std::string& what) : Error("Operation unsupported in " + backend_in + ": " + what) , backend{std::move(backend_in)} {} void - throwOperationUnsupportedInBackend(std::string backend, std::string what) + throwOperationUnsupportedInBackend(std::string backend, std::string const &what) { throw OperationUnsupportedInBackend( - std::move(backend), std::move(what)); + std::move(backend), what); } - WrongAPIUsage::WrongAPIUsage(std::string what) + WrongAPIUsage::WrongAPIUsage(const std::string& what) : Error("Wrong API usage: " + what) {} diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index a9af92e4a0..b1047d56d1 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -1241,7 +1241,7 @@ void ADIOS2IOHandlerImpl::listPaths( } for (auto &path : subdirs) { - parameters.paths->emplace_back(std::move(path)); + parameters.paths->emplace_back(path); } } @@ -1284,7 +1284,7 @@ void ADIOS2IOHandlerImpl::listDatasets( } for (auto &dataset : subdirs) { - parameters.datasets->emplace_back(std::move(dataset)); + parameters.datasets->emplace_back(dataset); } } @@ -1345,7 +1345,7 @@ void ADIOS2IOHandlerImpl::closePath( return; } auto position = setAndGetFilePosition(writable); - auto const positionString = filePositionToString(position); + auto positionString = filePositionToString(position); VERIFY( !auxiliary::ends_with(positionString, '/'), "[ADIOS2] Position string has unexpected format. This is a bug " @@ -1354,7 +1354,7 @@ void ADIOS2IOHandlerImpl::closePath( for (auto const &attr : fileData.availableAttributesPrefixed(positionString)) { - fileData.m_IO.RemoveAttribute(positionString + '/' + attr); + fileData.m_IO.RemoveAttribute(positionString.append("/").append(attr)); } } @@ -1492,7 +1492,7 @@ ADIOS2IOHandlerImpl::nameOfAttribute(Writable *writable, std::string attribute) { auto pos = setAndGetFilePosition(writable); return filePositionToString( - extendFilePosition(pos, auxiliary::removeSlashes(attribute))); + extendFilePosition(pos, auxiliary::removeSlashes(std::move(attribute)))); } GroupOrDataset ADIOS2IOHandlerImpl::groupOrDataset(Writable *writable) @@ -1501,7 +1501,7 @@ GroupOrDataset ADIOS2IOHandlerImpl::groupOrDataset(Writable *writable) } detail::BufferedActions & -ADIOS2IOHandlerImpl::getFileData(InvalidatableFile file, IfFileNotOpen flag) +ADIOS2IOHandlerImpl::getFileData(InvalidatableFile const &file, IfFileNotOpen flag) { VERIFY_ALWAYS( file.valid(), @@ -1515,7 +1515,7 @@ ADIOS2IOHandlerImpl::getFileData(InvalidatableFile file, IfFileNotOpen flag) case IfFileNotOpen::OpenImplicitly: { auto res = m_fileData.emplace( - std::move(file), + file, std::make_unique(*this, file)); return *res.first->second; } @@ -1531,7 +1531,7 @@ ADIOS2IOHandlerImpl::getFileData(InvalidatableFile file, IfFileNotOpen flag) } } -void ADIOS2IOHandlerImpl::dropFileData(InvalidatableFile file) +void ADIOS2IOHandlerImpl::dropFileData(InvalidatableFile const &file) { auto it = m_fileData.find(file); if (it != m_fileData.end()) @@ -1615,7 +1615,7 @@ namespace detail ADIOS2IOHandlerImpl &impl, adios2::IO &IO, std::string name, - std::shared_ptr resource) + std::shared_ptr const &resource) { (void)impl; /* @@ -1892,7 +1892,7 @@ namespace detail template void DatasetOpener::call( ADIOS2IOHandlerImpl *impl, - InvalidatableFile file, + InvalidatableFile const &file, const std::string &varName, Parameter ¶meters) { @@ -3394,7 +3394,7 @@ namespace detail #if openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string path, + std::string const &path, openPMD::Access at, MPI_Comm comm, json::TracingJSON options, @@ -3412,12 +3412,12 @@ ADIOS2IOHandler::ADIOS2IOHandler( #endif ADIOS2IOHandler::ADIOS2IOHandler( - std::string path, + std::string const &path, Access at, json::TracingJSON options, std::string engineType, std::string specifiedExtension) - : AbstractIOHandler(std::move(path), at) + : AbstractIOHandler(path, at) , m_impl{ this, std::move(options), @@ -3435,19 +3435,19 @@ ADIOS2IOHandler::flush(internal::ParsedFlushParams &flushParams) #if openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string path, + std::string const &path, Access at, MPI_Comm comm, json::TracingJSON, std::string, std::string) - : AbstractIOHandler(std::move(path), at, comm) + : AbstractIOHandler(path, at, comm) {} #endif // openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string path, Access at, json::TracingJSON, std::string, std::string) + std::string const &path, Access at, json::TracingJSON, std::string, std::string) : AbstractIOHandler(std::move(path), at) {} diff --git a/src/IO/AbstractIOHandlerHelper.cpp b/src/IO/AbstractIOHandlerHelper.cpp index c6cd69f8a5..e7125a201c 100644 --- a/src/IO/AbstractIOHandlerHelper.cpp +++ b/src/IO/AbstractIOHandlerHelper.cpp @@ -65,7 +65,7 @@ namespace #if openPMD_HAVE_MPI template <> std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension, @@ -139,7 +139,7 @@ std::unique_ptr createIOHandler( template <> std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension, @@ -217,13 +217,13 @@ std::unique_ptr createIOHandler( } std::unique_ptr createIOHandler( - std::string path, + std::string const &path, Access access, Format format, std::string originalExtension) { return createIOHandler( - std::move(path), + path, access, format, std::move(originalExtension), diff --git a/src/IO/AbstractIOHandlerImpl.cpp b/src/IO/AbstractIOHandlerImpl.cpp index af827704a1..01b489f4dd 100644 --- a/src/IO/AbstractIOHandlerImpl.cpp +++ b/src/IO/AbstractIOHandlerImpl.cpp @@ -38,7 +38,7 @@ AbstractIOHandlerImpl::AbstractIOHandlerImpl(AbstractIOHandler *handler) } void AbstractIOHandlerImpl::keepSynchronous( - Writable *writable, Parameter param) + Writable *writable, Parameter const ¶m) { writable->abstractFilePosition = param.otherWritable->abstractFilePosition; writable->written = true; diff --git a/src/IO/HDF5/HDF5Auxiliary.cpp b/src/IO/HDF5/HDF5Auxiliary.cpp index 53fb1fb390..75207720cd 100644 --- a/src/IO/HDF5/HDF5Auxiliary.cpp +++ b/src/IO/HDF5/HDF5Auxiliary.cpp @@ -314,7 +314,7 @@ std::string openPMD::concrete_h5_file_position(Writable *w) } std::vector openPMD::getOptimalChunkDims( - std::vector const dims, size_t const typeSize) + std::vector const &dims, size_t const typeSize) { auto const ndims = dims.size(); std::vector chunk_dims(dims.size()); diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index a0faac5fe8..1259a237b8 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -2802,8 +2802,8 @@ HDF5IOHandlerImpl::getFile(Writable *writable) #if openPMD_HAVE_HDF5 HDF5IOHandler::HDF5IOHandler( - std::string path, Access at, json::TracingJSON config) - : AbstractIOHandler(std::move(path), at) + std::string const &path, Access at, json::TracingJSON config) + : AbstractIOHandler(path, at) , m_impl{new HDF5IOHandlerImpl(this, std::move(config))} {} @@ -2815,7 +2815,7 @@ std::future HDF5IOHandler::flush(internal::ParsedFlushParams &) } #else HDF5IOHandler::HDF5IOHandler( - std::string path, Access at, json::TracingJSON /* config */) + std::string const &path, Access at, json::TracingJSON /* config */) : AbstractIOHandler(std::move(path), at) { throw std::runtime_error("openPMD-api built without HDF5 support"); diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index f7a6dc1a1c..8925dc742b 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -47,8 +47,8 @@ namespace openPMD #endif ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string path, Access at, MPI_Comm comm, json::TracingJSON config) - : AbstractIOHandler(std::move(path), at, comm) + std::string const &path, Access at, MPI_Comm comm, json::TracingJSON config) + : AbstractIOHandler(path, at, comm) , m_impl{new ParallelHDF5IOHandlerImpl(this, comm, std::move(config))} {} @@ -182,15 +182,15 @@ ParallelHDF5IOHandlerImpl::~ParallelHDF5IOHandlerImpl() #else #if openPMD_HAVE_MPI ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string path, Access at, MPI_Comm comm, json::TracingJSON /* config */) - : AbstractIOHandler(std::move(path), at, comm) + std::string const &path, Access at, MPI_Comm comm, json::TracingJSON /* config */) + : AbstractIOHandler(path, at, comm) { throw std::runtime_error("openPMD-api built without HDF5 support"); } #else ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string path, Access at, json::TracingJSON /* config */) - : AbstractIOHandler(std::move(path), at) + std::string const &path, Access at, json::TracingJSON /* config */) + : AbstractIOHandler(path, at) { throw std::runtime_error( "openPMD-api built without parallel support and without HDF5 support"); diff --git a/src/IO/InvalidatableFile.cpp b/src/IO/InvalidatableFile.cpp index 8d4b688673..0e4c9ac28e 100644 --- a/src/IO/InvalidatableFile.cpp +++ b/src/IO/InvalidatableFile.cpp @@ -21,7 +21,7 @@ #include "openPMD/IO/InvalidatableFile.hpp" -openPMD::InvalidatableFile::InvalidatableFile(std::string s) +openPMD::InvalidatableFile::InvalidatableFile(std::string const &s) : fileState{std::make_shared(s)} {} @@ -35,7 +35,7 @@ bool openPMD::InvalidatableFile::valid() const return fileState->valid; } -openPMD::InvalidatableFile &openPMD::InvalidatableFile::operator=(std::string s) +openPMD::InvalidatableFile &openPMD::InvalidatableFile::operator=(std::string const &s) { if (fileState) { diff --git a/src/IO/JSON/JSONIOHandler.cpp b/src/IO/JSON/JSONIOHandler.cpp index 7eb8a57278..7a0e7f1abb 100644 --- a/src/IO/JSON/JSONIOHandler.cpp +++ b/src/IO/JSON/JSONIOHandler.cpp @@ -26,13 +26,13 @@ namespace openPMD JSONIOHandler::~JSONIOHandler() = default; JSONIOHandler::JSONIOHandler( - std::string path, + std::string const &path, Access at, - openPMD::json::TracingJSON jsonCfg, + openPMD::json::TracingJSON const &jsonCfg, JSONIOHandlerImpl::FileFormat format, std::string originalExtension) : AbstractIOHandler{path, at} - , m_impl{this, std::move(jsonCfg), format, std::move(originalExtension)} + , m_impl{this, jsonCfg, format, std::move(originalExtension)} {} std::future JSONIOHandler::flush(internal::ParsedFlushParams &) diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index 73d50366f7..2944a43954 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -124,7 +124,7 @@ namespace JSONIOHandlerImpl::JSONIOHandlerImpl( AbstractIOHandler *handler, - openPMD::json::TracingJSON config, + openPMD::json::TracingJSON const &config, FileFormat format, std::string originalExtension) : AbstractIOHandlerImpl(handler) @@ -1011,13 +1011,13 @@ void JSONIOHandlerImpl::deregister( m_files.erase(writable); } -auto JSONIOHandlerImpl::getFilehandle(File fileName, Access access) +auto JSONIOHandlerImpl::getFilehandle(File const &fileName, Access access) -> std::tuple, std::istream *, std::ostream *> { VERIFY_ALWAYS( fileName.valid(), "[JSON] Tried opening a file that has been overwritten or deleted.") - auto path = fullPath(std::move(fileName)); + auto path = fullPath(fileName); auto fs = std::make_unique(); std::istream *istream = nullptr; std::ostream *ostream = nullptr; @@ -1057,7 +1057,7 @@ auto JSONIOHandlerImpl::getFilehandle(File fileName, Access access) return std::make_tuple(std::move(fs), istream, ostream); } -std::string JSONIOHandlerImpl::fullPath(File fileName) +std::string JSONIOHandlerImpl::fullPath(File const &fileName) { return fullPath(*fileName); } @@ -1189,7 +1189,7 @@ bool JSONIOHandlerImpl::hasKey(nlohmann::json const &j, KeyT &&key) return j.find(std::forward(key)) != j.end(); } -void JSONIOHandlerImpl::ensurePath(nlohmann::json *jsonp, std::string path) +void JSONIOHandlerImpl::ensurePath(nlohmann::json *jsonp, std::string const &path) { auto groups = auxiliary::split(path, "/"); for (std::string &group : groups) @@ -1206,7 +1206,7 @@ void JSONIOHandlerImpl::ensurePath(nlohmann::json *jsonp, std::string path) } std::tuple::iterator, bool> -JSONIOHandlerImpl::getPossiblyExisting(std::string file) +JSONIOHandlerImpl::getPossiblyExisting(std::string const &file) { auto it = std::find_if( @@ -1233,7 +1233,7 @@ JSONIOHandlerImpl::getPossiblyExisting(std::string file) std::move(name), it, newlyCreated); } -std::shared_ptr JSONIOHandlerImpl::obtainJsonContents(File file) +std::shared_ptr JSONIOHandlerImpl::obtainJsonContents(File const &file) { VERIFY_ALWAYS( file.valid(), @@ -1270,7 +1270,7 @@ nlohmann::json &JSONIOHandlerImpl::obtainJsonContents(Writable *writable) } void JSONIOHandlerImpl::putJsonContents( - File filename, + File const &filename, bool unsetDirty // = true ) { @@ -1306,7 +1306,7 @@ void JSONIOHandlerImpl::putJsonContents( } std::shared_ptr -JSONIOHandlerImpl::setAndGetFilePosition(Writable *writable, std::string extend) +JSONIOHandlerImpl::setAndGetFilePosition(Writable *writable, std::string const &extend) { std::string path; if (writable->abstractFilePosition) @@ -1388,7 +1388,7 @@ bool JSONIOHandlerImpl::isDataset(nlohmann::json const &j) return i != j.end() && i.value().is_array(); } -bool JSONIOHandlerImpl::isGroup(nlohmann::json::const_iterator it) +bool JSONIOHandlerImpl::isGroup(nlohmann::json::const_iterator const &it) { auto &j = it.value(); if (it.key() == "attributes" || it.key() == "platform_byte_widths" || diff --git a/src/Iteration.cpp b/src/Iteration.cpp index f4f7498fd0..c3b8b27869 100644 --- a/src/Iteration.cpp +++ b/src/Iteration.cpp @@ -372,7 +372,7 @@ void Iteration::reread(std::string const &path) } void Iteration::readFileBased( - std::string filePath, std::string const &groupPath, bool doBeginStep) + std::string const &filePath, std::string const &groupPath, bool doBeginStep) { if (doBeginStep) { diff --git a/src/ReadIterations.cpp b/src/ReadIterations.cpp index e92ede964f..8dbd41dd25 100644 --- a/src/ReadIterations.cpp +++ b/src/ReadIterations.cpp @@ -110,7 +110,7 @@ void SeriesIterator::close() } SeriesIterator::SeriesIterator( - Series series_in, std::optional parsePreference) + Series const &series_in, std::optional const &parsePreference) : m_data{std::make_shared>(std::in_place)} { auto &data = get(); @@ -615,7 +615,7 @@ ReadIterations::ReadIterations( Series series, Access access, std::optional parsePreference) - : m_series(std::move(series)), m_parsePreference(std::move(parsePreference)) + : m_series(series), m_parsePreference(parsePreference) { auto &data = m_series.get(); if (access == Access::READ_LINEAR && !data.m_sharedStatefulIterator) diff --git a/src/Series.cpp b/src/Series.cpp index 7d9a8413fb..8010b11ed3 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -508,7 +508,7 @@ namespace */ template int autoDetectPadding( - std::function isPartOfSeries, + std::function const &isPartOfSeries, std::string const &directory, MappingFunction &&mappingFunction) { @@ -707,7 +707,7 @@ void Series::initDefaults(IterationEncoding ie, bool initAll) std::future Series::flush_impl( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler) { IOHandler()->m_lastFlushSuccessful = true; @@ -745,7 +745,7 @@ std::future Series::flush_impl( void Series::flushFileBased( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler) { auto &series = get(); @@ -862,7 +862,7 @@ void Series::flushFileBased( void Series::flushGorVBased( iterations_iterator begin, iterations_iterator end, - internal::FlushParams flushParams, + internal::FlushParams const &flushParams, bool flushIOHandler) { auto &series = get(); @@ -1457,7 +1457,7 @@ creating new iterations. auto readSingleIteration = [&series, &pOpen, this]( IterationIndex_t index, - std::string path, + std::string const &path, bool guardAgainstRereading, bool beginStep) -> std::optional { if (series.iterations.contains(index)) diff --git a/src/WriteIterations.cpp b/src/WriteIterations.cpp index 334df0ec3a..ba7876e884 100644 --- a/src/WriteIterations.cpp +++ b/src/WriteIterations.cpp @@ -75,7 +75,7 @@ WriteIterations::mapped_type &WriteIterations::operator[](key_type &&key) auto lastIteration_v = lastIteration.value(); if (lastIteration_v.iterationIndex == key) { - return s.iterations.at(std::move(key)); + return s.iterations.at(key); } else { @@ -83,7 +83,7 @@ WriteIterations::mapped_type &WriteIterations::operator[](key_type &&key) } } s.currentlyOpen = key; - auto &res = s.iterations[std::move(key)]; + auto &res = s.iterations[key]; if (res.getStepStatus() == StepStatus::NoStep) { try diff --git a/src/auxiliary/Filesystem.cpp b/src/auxiliary/Filesystem.cpp index 38d8e209f8..40b765e5d5 100644 --- a/src/auxiliary/Filesystem.cpp +++ b/src/auxiliary/Filesystem.cpp @@ -152,7 +152,8 @@ bool remove_directory(std::string const &path) #endif for (auto const &entry : list_directory(path)) { - std::string partialPath = path + directory_separator + entry; + auto partialPath = path; + partialPath = partialPath.append(std::string(1,directory_separator)).append(entry); if (directory_exists(partialPath)) success &= remove_directory(partialPath); else if (file_exists(partialPath)) diff --git a/src/auxiliary/JSON.cpp b/src/auxiliary/JSON.cpp index 168cab7bf6..dd0825c33c 100644 --- a/src/auxiliary/JSON.cpp +++ b/src/auxiliary/JSON.cpp @@ -226,7 +226,7 @@ namespace res[pair.key()] = jsonToToml(pair.value(), currentPath); currentPath.pop_back(); } - return toml::value(std::move(res)); + return toml::value(res); } case nlohmann::json::value_t::array: { toml::value::array_type res; @@ -238,7 +238,7 @@ namespace res.emplace_back(jsonToToml(entry, currentPath)); currentPath.pop_back(); } - return toml::value(std::move(res)); + return toml::value(res); } case nlohmann::json::value_t::string: return val.get(); diff --git a/src/backend/Attributable.cpp b/src/backend/Attributable.cpp index 2d97dd0ff3..66083362ff 100644 --- a/src/backend/Attributable.cpp +++ b/src/backend/Attributable.cpp @@ -209,7 +209,7 @@ auto Attributable::myPath() const -> MyPath void Attributable::seriesFlush(internal::FlushParams flushParams) { - writable().seriesFlush(flushParams); + writable().seriesFlush(std::move(flushParams)); } void Attributable::flushAttributes(internal::FlushParams const &flushParams) @@ -311,7 +311,7 @@ void Attributable::readAttributes(ReadMode mode) } std::array arr; std::copy_n(vector.begin(), 7, arr.begin()); - setAttribute(key, std::move(arr)); + setAttribute(key, arr); } else { diff --git a/src/backend/Writable.cpp b/src/backend/Writable.cpp index f886e94046..a204b5d078 100644 --- a/src/backend/Writable.cpp +++ b/src/backend/Writable.cpp @@ -52,7 +52,7 @@ void Writable::seriesFlush(internal::FlushParams flushParams) auto series = Attributable({attributable, [](auto const *) {}}).retrieveSeries(); series.flush_impl( - series.iterations.begin(), series.iterations.end(), flushParams); + series.iterations.begin(), series.iterations.end(), std::move(flushParams)); } } // namespace openPMD diff --git a/src/binding/python/Attributable.cpp b/src/binding/python/Attributable.cpp index 88dbb95cbc..79d54e9953 100644 --- a/src/binding/python/Attributable.cpp +++ b/src/binding/python/Attributable.cpp @@ -155,61 +155,61 @@ bool setAttributeFromBufferInfo( ) ); else */ // std::cout << "+++++++++++ BUFFER: " << buf.format << std::endl; - if (buf.format.find("b") != std::string::npos) + if (buf.format.find('b') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("h") != std::string::npos) + else if (buf.format.find('h') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("i") != std::string::npos) + else if (buf.format.find('i') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("l") != std::string::npos) + else if (buf.format.find('l') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("q") != std::string::npos) + else if (buf.format.find('q') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("B") != std::string::npos) + else if (buf.format.find('B') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("H") != std::string::npos) + else if (buf.format.find('H') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("I") != std::string::npos) + else if (buf.format.find('I') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("L") != std::string::npos) + else if (buf.format.find('L') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("Q") != std::string::npos) + else if (buf.format.find('Q') != std::string::npos) return attr.setAttribute( key, std::vector( @@ -234,19 +234,19 @@ bool setAttributeFromBufferInfo( static_cast *>(buf.ptr), static_cast *>(buf.ptr) + buf.size)); - else if (buf.format.find("f") != std::string::npos) + else if (buf.format.find('f') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("d") != std::string::npos) + else if (buf.format.find('d') != std::string::npos) return attr.setAttribute( key, std::vector( static_cast(buf.ptr), static_cast(buf.ptr) + buf.size)); - else if (buf.format.find("g") != std::string::npos) + else if (buf.format.find('g') != std::string::npos) return attr.setAttribute( key, std::vector( @@ -349,7 +349,7 @@ bool setAttributeFromObject( py::object &obj, pybind11::dtype datatype) { - Datatype requestedDatatype = dtype_from_numpy(datatype); + Datatype requestedDatatype = dtype_from_numpy(std::move(datatype)); return switchNonVectorType( requestedDatatype, attr, key, obj); } @@ -401,7 +401,7 @@ void init_Attributable(py::module &m) std::string const &key, py::object &obj, pybind11::dtype datatype) { - return setAttributeFromObject(attr, key, obj, datatype); + return setAttributeFromObject(attr, key, obj, std::move(datatype)); }, py::arg("key"), py::arg("value"), diff --git a/src/binding/python/ChunkInfo.cpp b/src/binding/python/ChunkInfo.cpp index d86a579905..86bcb0128a 100644 --- a/src/binding/python/ChunkInfo.cpp +++ b/src/binding/python/ChunkInfo.cpp @@ -61,7 +61,7 @@ void init_Chunk(py::module &m) }, // __setstate__ - [](py::tuple t) { + [](py::tuple const &t) { // our state tuple has exactly three values if (t.size() != 3) throw std::runtime_error("Invalid state!"); diff --git a/src/binding/python/Dataset.cpp b/src/binding/python/Dataset.cpp index a67d7f1221..63965ba6de 100644 --- a/src/binding/python/Dataset.cpp +++ b/src/binding/python/Dataset.cpp @@ -33,8 +33,8 @@ void init_Dataset(py::module &m) .def(py::init(), py::arg("extent")) .def( py::init([](py::dtype dt, Extent e) { - auto const d = dtype_from_numpy(dt); - return new Dataset{d, e}; + auto const d = dtype_from_numpy(std::move(dt)); + return new Dataset{d, std::move(e)}; }), py::arg("dtype"), py::arg("extent")) @@ -45,8 +45,8 @@ void init_Dataset(py::module &m) py::arg("options")) .def( py::init([](py::dtype dt, Extent e, std::string options) { - auto const d = dtype_from_numpy(dt); - return new Dataset{d, e, std::move(options)}; + auto const d = dtype_from_numpy(std::move(dt)); + return new Dataset{d, std::move(e), std::move(options)}; }), py::arg("dtype"), py::arg("extent"), diff --git a/src/binding/python/Datatype.cpp b/src/binding/python/Datatype.cpp index 9d53fba5ca..1a603855b0 100644 --- a/src/binding/python/Datatype.cpp +++ b/src/binding/python/Datatype.cpp @@ -58,7 +58,7 @@ void init_Datatype(py::module &m) .value("BOOL", Datatype::BOOL) .value("UNDEFINED", Datatype::UNDEFINED); - m.def("determine_datatype", [](py::dtype const dt) { + m.def("determine_datatype", [](py::dtype const &dt) { return dtype_from_numpy(dt); }); m.def("determine_datatype", [](py::array const &a) { diff --git a/src/binding/python/PatchRecordComponent.cpp b/src/binding/python/PatchRecordComponent.cpp index e668f7a1d9..e537f60538 100644 --- a/src/binding/python/PatchRecordComponent.cpp +++ b/src/binding/python/PatchRecordComponent.cpp @@ -91,7 +91,7 @@ void init_PatchRecordComponent(py::module &m) // all buffer types .def( "store", - [](PatchRecordComponent &prc, uint64_t idx, py::buffer a) { + [](PatchRecordComponent &prc, uint64_t idx, py::buffer const &a) { py::buffer_info buf = a.request(); auto const dtype = dtype_from_bufferformat(buf.format); diff --git a/src/binding/python/RecordComponent.cpp b/src/binding/python/RecordComponent.cpp index ee8bb7d3bd..016e2db7d5 100644 --- a/src/binding/python/RecordComponent.cpp +++ b/src/binding/python/RecordComponent.cpp @@ -928,7 +928,7 @@ void init_RecordComponent(py::module &m) .def( "make_empty", [](RecordComponent &rc, - pybind11::dtype const dt, + pybind11::dtype const &dt, uint8_t dimensionality) { return rc.makeEmpty(dtype_from_numpy(dt), dimensionality); }) @@ -1110,7 +1110,7 @@ void init_RecordComponent(py::module &m) py::arg_v("extent", Extent(1, -1u), "array.shape")) .def_property_readonly_static( - "SCALAR", [](py::object) { return RecordComponent::SCALAR; }) + "SCALAR", [](py::object const& ) { return RecordComponent::SCALAR; }) // TODO remove in future versions (deprecated) .def("set_unit_SI", &RecordComponent::setUnitSI) // deprecated diff --git a/src/cli/ls.cpp b/src/cli/ls.cpp index 65bb226602..3f13770f56 100644 --- a/src/cli/ls.cpp +++ b/src/cli/ls.cpp @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) { std::vector str_argv; + str_argv.reserve(argc); for (int i = 0; i < argc; ++i) str_argv.emplace_back(argv[i]); diff --git a/src/version.cpp b/src/version.cpp index 6fa0a9ecfa..77d870c9e8 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -30,7 +30,7 @@ std::string openPMD::getVersion() << OPENPMDAPI_VERSION_PATCH; if (std::string(OPENPMDAPI_VERSION_LABEL).size() > 0) api << "-" << OPENPMDAPI_VERSION_LABEL; - std::string const apistr = api.str(); + std::string apistr = api.str(); return apistr; } @@ -39,7 +39,7 @@ std::string openPMD::getStandard() std::stringstream standard; standard << OPENPMD_STANDARD_MAJOR << "." << OPENPMD_STANDARD_MINOR << "." << OPENPMD_STANDARD_PATCH; - std::string const standardstr = standard.str(); + std::string standardstr = standard.str(); return standardstr; } @@ -49,6 +49,6 @@ std::string openPMD::getStandardMinimum() standardMin << OPENPMD_STANDARD_MIN_MAJOR << "." << OPENPMD_STANDARD_MIN_MINOR << "." << OPENPMD_STANDARD_MIN_PATCH; - std::string const standardMinstr = standardMin.str(); + std::string standardMinstr = standardMin.str(); return standardMinstr; } diff --git a/test/AuxiliaryTest.cpp b/test/AuxiliaryTest.cpp index 491bb37794..85d9c7c26d 100644 --- a/test/AuxiliaryTest.cpp +++ b/test/AuxiliaryTest.cpp @@ -175,7 +175,7 @@ struct structure : public TestHelper } structure &setText(std::string newText) { - setAttribute("text", newText); + setAttribute("text", std::move(newText)); return *this; } }; @@ -308,7 +308,7 @@ struct AttributedWidget : public TestHelper AttributedWidget() : TestHelper() {} - Attribute::resource get(std::string key) + Attribute::resource get(std::string const &key) { return getAttribute(key).getResource(); } @@ -380,7 +380,7 @@ struct Dotty : public TestHelper } Dotty &setAtt3(std::string s) { - setAttribute("att3", s); + setAttribute("att3", std::move(s)); return *this; } }; diff --git a/test/ParallelIOTest.cpp b/test/ParallelIOTest.cpp index d884766f15..215ff4f2c9 100644 --- a/test/ParallelIOTest.cpp +++ b/test/ParallelIOTest.cpp @@ -115,7 +115,7 @@ TEST_CASE("parallel_multi_series_test", "[parallel]") void write_test_zero_extent( bool fileBased, - std::string file_ending, + std::string const &file_ending, bool writeAllChunks, bool declareFromAll) { @@ -379,7 +379,7 @@ TEST_CASE("no_parallel_hdf5", "[parallel][hdf5]") #endif #if openPMD_HAVE_ADIOS2 && openPMD_HAVE_MPI -void available_chunks_test(std::string file_ending) +void available_chunks_test(std::string const &file_ending) { int r_mpi_rank{-1}, r_mpi_size{-1}; MPI_Comm_rank(MPI_COMM_WORLD, &r_mpi_rank); @@ -628,7 +628,7 @@ TEST_CASE("hzdr_adios_sample_content_test", "[parallel][adios2][bp3]") #endif #if openPMD_HAVE_MPI -void write_4D_test(std::string file_ending) +void write_4D_test(std::string const &file_ending) { int mpi_s{-1}; int mpi_r{-1}; @@ -662,7 +662,7 @@ TEST_CASE("write_4D_test", "[parallel]") } } -void write_makeconst_some(std::string file_ending) +void write_makeconst_some(std::string const &file_ending) { int mpi_s{-1}; int mpi_r{-1}; @@ -695,7 +695,7 @@ TEST_CASE("write_makeconst_some", "[parallel]") } } -void close_iteration_test(std::string file_ending) +void close_iteration_test(std::string const &file_ending) { int i_mpi_rank{-1}, i_mpi_size{-1}; MPI_Comm_rank(MPI_COMM_WORLD, &i_mpi_rank); @@ -765,7 +765,7 @@ TEST_CASE("close_iteration_test", "[parallel]") } } -void file_based_write_read(std::string file_ending) +void file_based_write_read(std::string const &file_ending) { namespace io = openPMD; @@ -872,7 +872,7 @@ TEST_CASE("file_based_write_read", "[parallel]") } } -void hipace_like_write(std::string file_ending) +void hipace_like_write(std::string const &file_ending) { namespace io = openPMD; @@ -1397,7 +1397,7 @@ void append_mode( std::string const &extension, bool variableBased, ParseMode parseMode, - std::string jsonConfig = "{}") + std::string const &jsonConfig = "{}") { std::string filename = (variableBased ? "../samples/append/append_variablebased." @@ -1415,7 +1415,7 @@ void append_mode( std::vector data(10, 999); auto writeSomeIterations = [&data, mpi_size, mpi_rank]( WriteIterations &&writeIterations, - std::vector indices) { + std::vector const &indices) { for (auto index : indices) { auto it = writeIterations[index]; diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 962ca636aa..e3cdd3d956 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -67,7 +67,7 @@ std::vector testedBackends() if (lookup != extensions.end()) { std::string extension = lookup->second; - res.push_back({std::move(pair.first), std::move(extension)}); + res.push_back({pair.first, std::move(extension)}); } } } @@ -414,7 +414,7 @@ TEST_CASE("multiple_series_handles_test", "[serial]") #endif } -void close_iteration_test(std::string file_ending) +void close_iteration_test(std::string const &file_ending) { std::string name = "../samples/close_iterations_%T." + file_ending; @@ -500,7 +500,7 @@ TEST_CASE("close_iteration_test", "[serial]") } void close_iteration_interleaved_test( - std::string const file_ending, IterationEncoding const it_encoding) + std::string const &file_ending, IterationEncoding const it_encoding) { std::string name = "../samples/close_iterations_interleaved_"; if (it_encoding == IterationEncoding::fileBased) @@ -579,7 +579,7 @@ TEST_CASE("close_iteration_interleaved_test", "[serial]") } } -void close_and_copy_attributable_test(std::string file_ending) +void close_and_copy_attributable_test(std::string const &file_ending) { using position_t = int; @@ -750,7 +750,7 @@ TEST_CASE("close_iteration_throws_test", "[serial]") } #endif -inline void empty_dataset_test(std::string file_ending) +inline void empty_dataset_test(std::string const &file_ending) { { Series series( @@ -854,7 +854,7 @@ TEST_CASE("empty_dataset_test", "[serial]") } } -inline void constant_scalar(std::string file_ending) +inline void constant_scalar(std::string const &file_ending) { Mesh::Geometry const geometry = Mesh::Geometry::spherical; std::string const geometryParameters = "dummyGeometryParameters"; @@ -1126,7 +1126,7 @@ TEST_CASE("flush_without_position_positionOffset", "[serial]") } } -inline void particle_patches(std::string file_ending) +inline void particle_patches(std::string const &file_ending) { constexpr auto SCALAR = openPMD::RecordComponent::SCALAR; @@ -2132,7 +2132,7 @@ TEST_CASE("fileBased_write_test", "[serial]") } } -inline void sample_write_thetaMode(std::string file_ending) +inline void sample_write_thetaMode(std::string const &file_ending) { Series o = Series( std::string("../samples/thetaMode_%05T.").append(file_ending), @@ -2468,8 +2468,8 @@ inline void optional_paths_110_test(const std::string &backend) } void git_early_chunk_query( - std::string const filename, - std::string const species, + std::string const &filename, + std::string const &species, int const step, std::string const &jsonConfig = "{}") { @@ -5795,7 +5795,7 @@ void variableBasedParticleData() for (size_t i = 0; i < 3; ++i) { - std::string dim = dimensions[i]; + std::string const &dim = dimensions[i]; RecordComponent rc = electronPositions[dim]; loadedChunks[i] = rc.loadChunk( Offset(rc.getDimensionality(), 0), rc.getExtent()); @@ -5806,7 +5806,7 @@ void variableBasedParticleData() for (size_t i = 0; i < 3; ++i) { - std::string dim = dimensions[i]; + std::string const &dim = dimensions[i]; Extent const &extent = extents[i]; auto chunk = loadedChunks[i]; for (size_t j = 0; j < extent[0]; ++j) @@ -5997,7 +5997,7 @@ TEST_CASE("automatically_deactivate_span", "[serial][adios2]") // @todo Upon switching to ADIOS2 2.7.0, test this the other way around also void iterate_nonstreaming_series( - std::string const &file, bool variableBasedLayout, std::string jsonConfig) + std::string const &file, bool variableBasedLayout, std::string const &jsonConfig) { constexpr size_t extent = 100; { @@ -6417,9 +6417,9 @@ void deferred_parsing(std::string const &extension) { padding += "0"; } - infix = padding + infix; + infix = padding.append(infix); std::ofstream file; - file.open(basename + infix + "." + extension); + file.open(basename.append(infix).append(".").append(extension)); file.close(); } } @@ -6806,7 +6806,7 @@ TEST_CASE("late_setting_of_iterationencoding", "[serial]") auxiliary::file_exists("../samples/change_name_and_encoding_10.json")); } -void varying_pattern(std::string const file_ending) +void varying_pattern(std::string const &file_ending) { { std::string filename = "../samples/varying_pattern_%06T." + file_ending; @@ -6894,7 +6894,7 @@ void append_mode( std::string const &filename, bool variableBased, ParseMode parseMode, - std::string jsonConfig = "{}") + std::string const &jsonConfig = "{}") { if (auxiliary::directory_exists("../samples/append")) { @@ -6903,7 +6903,7 @@ void append_mode( std::vector data(10, 999); auto writeSomeIterations = [&data]( WriteIterations &&writeIterations, - std::vector indices) { + std::vector const &indices) { for (auto index : indices) { auto it = writeIterations[index]; @@ -7270,7 +7270,7 @@ void append_mode_filebased(std::string const &extension) } })END"; auto writeSomeIterations = [](WriteIterations &&writeIterations, - std::vector indices) { + std::vector const &indices) { for (auto index : indices) { auto it = writeIterations[index]; From 05b956ef3d573a354b5756e53eb741e92200ce42 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 03:25:34 +0000 Subject: [PATCH 02/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- include/openPMD/Dataset.hpp | 4 ++-- include/openPMD/Datatype.hpp | 2 +- include/openPMD/Error.hpp | 5 +++-- include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp | 3 ++- include/openPMD/IO/AbstractIOHandlerImpl.hpp | 4 ++-- .../openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp | 3 ++- include/openPMD/Iteration.hpp | 4 +++- include/openPMD/ReadIterations.hpp | 3 ++- include/openPMD/ThrowError.hpp | 4 ++-- include/openPMD/cli/ls.hpp | 2 +- src/Dataset.cpp | 2 +- src/Datatype.cpp | 2 +- src/Error.cpp | 11 +++++------ src/IO/ADIOS/ADIOS2IOHandler.cpp | 17 ++++++++++------- src/IO/HDF5/ParallelHDF5IOHandler.cpp | 5 ++++- src/IO/InvalidatableFile.cpp | 3 ++- src/IO/JSON/JSONIOHandlerImpl.cpp | 10 ++++++---- src/ReadIterations.cpp | 3 ++- src/auxiliary/Filesystem.cpp | 3 ++- src/backend/Writable.cpp | 4 +++- src/binding/python/Attributable.cpp | 3 ++- src/binding/python/RecordComponent.cpp | 3 ++- test/SerialIOTest.cpp | 4 +++- 23 files changed, 63 insertions(+), 41 deletions(-) diff --git a/include/openPMD/Dataset.hpp b/include/openPMD/Dataset.hpp index 9b9540da4d..68de3b5879 100644 --- a/include/openPMD/Dataset.hpp +++ b/include/openPMD/Dataset.hpp @@ -37,7 +37,7 @@ class Dataset friend class RecordComponent; public: - Dataset(Datatype, Extent const&, std::string options = "{}"); + Dataset(Datatype, Extent const &, std::string options = "{}"); /** * @brief Constructor that sets the datatype to undefined. @@ -45,7 +45,7 @@ class Dataset * Helpful for resizing datasets, since datatypes need not be given twice. * */ - Dataset(Extent const&); + Dataset(Extent const &); Dataset &extend(Extent newExtent); diff --git a/include/openPMD/Datatype.hpp b/include/openPMD/Datatype.hpp index 6b368ee523..c83c865e59 100644 --- a/include/openPMD/Datatype.hpp +++ b/include/openPMD/Datatype.hpp @@ -739,7 +739,7 @@ Datatype toVectorType(Datatype dt); std::string datatypeToString(Datatype dt); -Datatype stringToDatatype(const std::string& s); +Datatype stringToDatatype(const std::string &s); void warnWrongDtype(std::string const &key, Datatype store, Datatype request); diff --git a/include/openPMD/Error.hpp b/include/openPMD/Error.hpp index 8eca11ceda..70aca03f87 100644 --- a/include/openPMD/Error.hpp +++ b/include/openPMD/Error.hpp @@ -50,7 +50,8 @@ namespace error { public: std::string backend; - OperationUnsupportedInBackend(std::string backend_in, const std::string& what); + OperationUnsupportedInBackend( + std::string backend_in, const std::string &what); }; /** @@ -62,7 +63,7 @@ namespace error class WrongAPIUsage : public Error { public: - WrongAPIUsage(const std::string& what); + WrongAPIUsage(const std::string &what); }; class BackendConfigSchema : public Error diff --git a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp index 2e70e76cf0..ad2f4089ba 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp @@ -391,7 +391,8 @@ class ADIOS2IOHandlerImpl ThrowError }; - detail::BufferedActions &getFileData(InvalidatableFile const &file, IfFileNotOpen); + detail::BufferedActions & + getFileData(InvalidatableFile const &file, IfFileNotOpen); void dropFileData(InvalidatableFile const &file); diff --git a/include/openPMD/IO/AbstractIOHandlerImpl.hpp b/include/openPMD/IO/AbstractIOHandlerImpl.hpp index 48b8efb02b..dafbc24111 100644 --- a/include/openPMD/IO/AbstractIOHandlerImpl.hpp +++ b/include/openPMD/IO/AbstractIOHandlerImpl.hpp @@ -390,8 +390,8 @@ class AbstractIOHandlerImpl * Using the default implementation (which copies the abstractFilePath * into the current writable) should be enough for all backends. */ - void - keepSynchronous(Writable *, Parameter const ¶m); + void keepSynchronous( + Writable *, Parameter const ¶m); /** Notify the backend that the Writable has been / will be deallocated. * diff --git a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp index 26d6ca8673..8bc7142b2f 100644 --- a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp +++ b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp @@ -39,7 +39,8 @@ class ParallelHDF5IOHandler : public AbstractIOHandler ParallelHDF5IOHandler( std::string const &path, Access, MPI_Comm, json::TracingJSON config); #else - ParallelHDF5IOHandler(std::string const &path, Access, json::TracingJSON config); + ParallelHDF5IOHandler( + std::string const &path, Access, json::TracingJSON config); #endif ~ParallelHDF5IOHandler() override; diff --git a/include/openPMD/Iteration.hpp b/include/openPMD/Iteration.hpp index e340712658..49e8c3296c 100644 --- a/include/openPMD/Iteration.hpp +++ b/include/openPMD/Iteration.hpp @@ -284,7 +284,9 @@ class Iteration : public Attributable */ void reread(std::string const &path); void readFileBased( - std::string const &filePath, std::string const &groupPath, bool beginStep); + std::string const &filePath, + std::string const &groupPath, + bool beginStep); void readGorVBased(std::string const &groupPath, bool beginStep); void read_impl(std::string const &groupPath); void readMeshes(std::string const &meshesPath); diff --git a/include/openPMD/ReadIterations.hpp b/include/openPMD/ReadIterations.hpp index cc5817984f..35f2f740ce 100644 --- a/include/openPMD/ReadIterations.hpp +++ b/include/openPMD/ReadIterations.hpp @@ -77,7 +77,8 @@ class SeriesIterator explicit SeriesIterator(); SeriesIterator( - Series const&, std::optional const &parsePreference); + Series const &, + std::optional const &parsePreference); SeriesIterator &operator++(); diff --git a/include/openPMD/ThrowError.hpp b/include/openPMD/ThrowError.hpp index 52286782b2..3888c40b12 100644 --- a/include/openPMD/ThrowError.hpp +++ b/include/openPMD/ThrowError.hpp @@ -50,8 +50,8 @@ enum class Reason [[noreturn]] OPENPMDAPI_EXPORT void throwBackendConfigSchema(std::vector jsonPath, std::string what); -[[noreturn]] OPENPMDAPI_EXPORT void -throwOperationUnsupportedInBackend(std::string backend, std::string const &what); +[[noreturn]] OPENPMDAPI_EXPORT void throwOperationUnsupportedInBackend( + std::string backend, std::string const &what); [[noreturn]] OPENPMDAPI_EXPORT void throwReadError( AffectedObject affectedObject, diff --git a/include/openPMD/cli/ls.hpp b/include/openPMD/cli/ls.hpp index c56da30254..b61e34e13d 100644 --- a/include/openPMD/cli/ls.hpp +++ b/include/openPMD/cli/ls.hpp @@ -54,7 +54,7 @@ namespace cli << " ./samples/serial_patch.bp\n"; } - inline void print_version(std::string const & program_name) + inline void print_version(std::string const &program_name) { std::cout << program_name << " (openPMD-api) " << getVersion() << "\n"; diff --git a/src/Dataset.cpp b/src/Dataset.cpp index 7621564b42..565bab0ad3 100644 --- a/src/Dataset.cpp +++ b/src/Dataset.cpp @@ -25,7 +25,7 @@ namespace openPMD { -Dataset::Dataset(Datatype d, const Extent& e, std::string options_in) +Dataset::Dataset(Datatype d, const Extent &e, std::string options_in) : extent{e} , dtype{d} , rank{static_cast(e.size())} diff --git a/src/Datatype.cpp b/src/Datatype.cpp index 09f9e45f34..298bcc8790 100644 --- a/src/Datatype.cpp +++ b/src/Datatype.cpp @@ -163,7 +163,7 @@ std::ostream &operator<<(std::ostream &os, openPMD::Datatype const &d) return os; } -Datatype stringToDatatype(const std::string& s) +Datatype stringToDatatype(const std::string &s) { static std::unordered_map m{ {"CHAR", Datatype::CHAR}, diff --git a/src/Error.cpp b/src/Error.cpp index eb08588b84..2d4a20032d 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -12,19 +12,18 @@ const char *Error::what() const noexcept namespace error { OperationUnsupportedInBackend::OperationUnsupportedInBackend( - std::string backend_in, const std::string& what) + std::string backend_in, const std::string &what) : Error("Operation unsupported in " + backend_in + ": " + what) , backend{std::move(backend_in)} {} - void - throwOperationUnsupportedInBackend(std::string backend, std::string const &what) + void throwOperationUnsupportedInBackend( + std::string backend, std::string const &what) { - throw OperationUnsupportedInBackend( - std::move(backend), what); + throw OperationUnsupportedInBackend(std::move(backend), what); } - WrongAPIUsage::WrongAPIUsage(const std::string& what) + WrongAPIUsage::WrongAPIUsage(const std::string &what) : Error("Wrong API usage: " + what) {} diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index b1047d56d1..027d884a0d 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -1491,8 +1491,8 @@ std::string ADIOS2IOHandlerImpl::nameOfAttribute(Writable *writable, std::string attribute) { auto pos = setAndGetFilePosition(writable); - return filePositionToString( - extendFilePosition(pos, auxiliary::removeSlashes(std::move(attribute)))); + return filePositionToString(extendFilePosition( + pos, auxiliary::removeSlashes(std::move(attribute)))); } GroupOrDataset ADIOS2IOHandlerImpl::groupOrDataset(Writable *writable) @@ -1500,8 +1500,8 @@ GroupOrDataset ADIOS2IOHandlerImpl::groupOrDataset(Writable *writable) return setAndGetFilePosition(writable)->gd; } -detail::BufferedActions & -ADIOS2IOHandlerImpl::getFileData(InvalidatableFile const &file, IfFileNotOpen flag) +detail::BufferedActions &ADIOS2IOHandlerImpl::getFileData( + InvalidatableFile const &file, IfFileNotOpen flag) { VERIFY_ALWAYS( file.valid(), @@ -1515,8 +1515,7 @@ ADIOS2IOHandlerImpl::getFileData(InvalidatableFile const &file, IfFileNotOpen fl case IfFileNotOpen::OpenImplicitly: { auto res = m_fileData.emplace( - file, - std::make_unique(*this, file)); + file, std::make_unique(*this, file)); return *res.first->second; } case IfFileNotOpen::ThrowError: @@ -3447,7 +3446,11 @@ ADIOS2IOHandler::ADIOS2IOHandler( #endif // openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string const &path, Access at, json::TracingJSON, std::string, std::string) + std::string const &path, + Access at, + json::TracingJSON, + std::string, + std::string) : AbstractIOHandler(std::move(path), at) {} diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index 8925dc742b..dcc8676f8b 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -182,7 +182,10 @@ ParallelHDF5IOHandlerImpl::~ParallelHDF5IOHandlerImpl() #else #if openPMD_HAVE_MPI ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string const &path, Access at, MPI_Comm comm, json::TracingJSON /* config */) + std::string const &path, + Access at, + MPI_Comm comm, + json::TracingJSON /* config */) : AbstractIOHandler(path, at, comm) { throw std::runtime_error("openPMD-api built without HDF5 support"); diff --git a/src/IO/InvalidatableFile.cpp b/src/IO/InvalidatableFile.cpp index 0e4c9ac28e..4825f91789 100644 --- a/src/IO/InvalidatableFile.cpp +++ b/src/IO/InvalidatableFile.cpp @@ -35,7 +35,8 @@ bool openPMD::InvalidatableFile::valid() const return fileState->valid; } -openPMD::InvalidatableFile &openPMD::InvalidatableFile::operator=(std::string const &s) +openPMD::InvalidatableFile & +openPMD::InvalidatableFile::operator=(std::string const &s) { if (fileState) { diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index 2944a43954..6cd4a5c805 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -1189,7 +1189,8 @@ bool JSONIOHandlerImpl::hasKey(nlohmann::json const &j, KeyT &&key) return j.find(std::forward(key)) != j.end(); } -void JSONIOHandlerImpl::ensurePath(nlohmann::json *jsonp, std::string const &path) +void JSONIOHandlerImpl::ensurePath( + nlohmann::json *jsonp, std::string const &path) { auto groups = auxiliary::split(path, "/"); for (std::string &group : groups) @@ -1233,7 +1234,8 @@ JSONIOHandlerImpl::getPossiblyExisting(std::string const &file) std::move(name), it, newlyCreated); } -std::shared_ptr JSONIOHandlerImpl::obtainJsonContents(File const &file) +std::shared_ptr +JSONIOHandlerImpl::obtainJsonContents(File const &file) { VERIFY_ALWAYS( file.valid(), @@ -1305,8 +1307,8 @@ void JSONIOHandlerImpl::putJsonContents( } } -std::shared_ptr -JSONIOHandlerImpl::setAndGetFilePosition(Writable *writable, std::string const &extend) +std::shared_ptr JSONIOHandlerImpl::setAndGetFilePosition( + Writable *writable, std::string const &extend) { std::string path; if (writable->abstractFilePosition) diff --git a/src/ReadIterations.cpp b/src/ReadIterations.cpp index 8dbd41dd25..afa6d8b1af 100644 --- a/src/ReadIterations.cpp +++ b/src/ReadIterations.cpp @@ -110,7 +110,8 @@ void SeriesIterator::close() } SeriesIterator::SeriesIterator( - Series const &series_in, std::optional const &parsePreference) + Series const &series_in, + std::optional const &parsePreference) : m_data{std::make_shared>(std::in_place)} { auto &data = get(); diff --git a/src/auxiliary/Filesystem.cpp b/src/auxiliary/Filesystem.cpp index 40b765e5d5..f7ccbeb0e1 100644 --- a/src/auxiliary/Filesystem.cpp +++ b/src/auxiliary/Filesystem.cpp @@ -153,7 +153,8 @@ bool remove_directory(std::string const &path) for (auto const &entry : list_directory(path)) { auto partialPath = path; - partialPath = partialPath.append(std::string(1,directory_separator)).append(entry); + partialPath = partialPath.append(std::string(1, directory_separator)) + .append(entry); if (directory_exists(partialPath)) success &= remove_directory(partialPath); else if (file_exists(partialPath)) diff --git a/src/backend/Writable.cpp b/src/backend/Writable.cpp index a204b5d078..dfac17c33d 100644 --- a/src/backend/Writable.cpp +++ b/src/backend/Writable.cpp @@ -52,7 +52,9 @@ void Writable::seriesFlush(internal::FlushParams flushParams) auto series = Attributable({attributable, [](auto const *) {}}).retrieveSeries(); series.flush_impl( - series.iterations.begin(), series.iterations.end(), std::move(flushParams)); + series.iterations.begin(), + series.iterations.end(), + std::move(flushParams)); } } // namespace openPMD diff --git a/src/binding/python/Attributable.cpp b/src/binding/python/Attributable.cpp index 79d54e9953..a3fa63cdca 100644 --- a/src/binding/python/Attributable.cpp +++ b/src/binding/python/Attributable.cpp @@ -401,7 +401,8 @@ void init_Attributable(py::module &m) std::string const &key, py::object &obj, pybind11::dtype datatype) { - return setAttributeFromObject(attr, key, obj, std::move(datatype)); + return setAttributeFromObject( + attr, key, obj, std::move(datatype)); }, py::arg("key"), py::arg("value"), diff --git a/src/binding/python/RecordComponent.cpp b/src/binding/python/RecordComponent.cpp index 016e2db7d5..a9b1174389 100644 --- a/src/binding/python/RecordComponent.cpp +++ b/src/binding/python/RecordComponent.cpp @@ -1110,7 +1110,8 @@ void init_RecordComponent(py::module &m) py::arg_v("extent", Extent(1, -1u), "array.shape")) .def_property_readonly_static( - "SCALAR", [](py::object const& ) { return RecordComponent::SCALAR; }) + "SCALAR", + [](py::object const &) { return RecordComponent::SCALAR; }) // TODO remove in future versions (deprecated) .def("set_unit_SI", &RecordComponent::setUnitSI) // deprecated diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index e3cdd3d956..467495e35d 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -5997,7 +5997,9 @@ TEST_CASE("automatically_deactivate_span", "[serial][adios2]") // @todo Upon switching to ADIOS2 2.7.0, test this the other way around also void iterate_nonstreaming_series( - std::string const &file, bool variableBasedLayout, std::string const &jsonConfig) + std::string const &file, + bool variableBasedLayout, + std::string const &jsonConfig) { constexpr size_t extent = 100; { From 495cef064cdba82a6645d5e930b2186025bdeab1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:27:20 +0000 Subject: [PATCH 03/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/IO/ADIOS/ADIOS2IOHandler.cpp | 25 ++++++++----------------- src/backend/Writable.cpp | 4 +--- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 416bed5c86..b616fd70e7 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -3400,12 +3400,7 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string const &engineType, std::string const &specifiedExtension) : AbstractIOHandler(path, at, comm) - , m_impl{ - this, - comm, - options, - engineType, - specifiedExtension} + , m_impl{this, comm, options, engineType, specifiedExtension} {} #endif @@ -3417,11 +3412,7 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string const &engineType, std::string const &specifiedExtension) : AbstractIOHandler(path, at) - , m_impl{ - this, - options, - engineType, - specifiedExtension} + , m_impl{this, options, engineType, specifiedExtension} {} std::future @@ -3437,9 +3428,9 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, Access at, MPI_Comm comm, - json::TracingJSON const&, - std::string const&, - std::string const&) + json::TracingJSON const &, + std::string const &, + std::string const &) : AbstractIOHandler(path, at, comm) {} @@ -3448,9 +3439,9 @@ ADIOS2IOHandler::ADIOS2IOHandler( ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, Access at, - json::TracingJSON const&, - std::string const&, - std::string const&) + json::TracingJSON const &, + std::string const &, + std::string const &) : AbstractIOHandler(path, at) {} diff --git a/src/backend/Writable.cpp b/src/backend/Writable.cpp index 0acd21d92a..97d13ce5f0 100644 --- a/src/backend/Writable.cpp +++ b/src/backend/Writable.cpp @@ -52,9 +52,7 @@ void Writable::seriesFlush(internal::FlushParams const &flushParams) auto series = Attributable({attributable, [](auto const *) {}}).retrieveSeries(); series.flush_impl( - series.iterations.begin(), - series.iterations.end(), - flushParams); + series.iterations.begin(), series.iterations.end(), flushParams); } } // namespace openPMD From e400d5ee03f93b2b90aa1552193ef84590b307ff Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 4 Oct 2023 11:30:04 +0200 Subject: [PATCH 04/15] address residual issues found with clang-tidy --- examples/8_benchmark_parallel.cpp | 1 + include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp | 12 +++--- .../openPMD/IO/AbstractIOHandlerHelper.hpp | 6 +-- include/openPMD/IO/DummyIOHandler.hpp | 2 +- include/openPMD/ReadIterations.hpp | 2 +- include/openPMD/backend/Attributable.hpp | 2 +- include/openPMD/backend/Writable.hpp | 2 +- src/IO/ADIOS/ADIOS2IOHandler.cpp | 40 +++++++++---------- src/IO/AbstractIOHandlerHelper.cpp | 33 ++++++++------- src/IO/DummyIOHandler.cpp | 4 +- src/ReadIterations.cpp | 4 +- src/Series.cpp | 6 +-- src/backend/Attributable.cpp | 4 +- src/backend/Writable.cpp | 4 +- src/binding/python/Dataset.cpp | 8 ++-- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/examples/8_benchmark_parallel.cpp b/examples/8_benchmark_parallel.cpp index c8c1db88f8..2dc63632ff 100644 --- a/examples/8_benchmark_parallel.cpp +++ b/examples/8_benchmark_parallel.cpp @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) // CLI parsing std::vector str_argv; + str_argv.reserve(argc); for (int i = 0; i < argc; ++i) str_argv.emplace_back(argv[i]); bool weak_scaling = false; diff --git a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp index ad2f4089ba..f82564c3ff 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp @@ -1199,18 +1199,18 @@ class ADIOS2IOHandler : public AbstractIOHandler std::string const &path, Access, MPI_Comm, - json::TracingJSON options, - std::string engineType, - std::string specifiedExtension); + json::TracingJSON const &options, + std::string const &engineType, + std::string const &specifiedExtension); #endif ADIOS2IOHandler( std::string const &path, Access, - json::TracingJSON options, - std::string engineType, - std::string specifiedExtension); + json::TracingJSON const &options, + std::string const &engineType, + std::string const &specifiedExtension); std::string backendName() const override { diff --git a/include/openPMD/IO/AbstractIOHandlerHelper.hpp b/include/openPMD/IO/AbstractIOHandlerHelper.hpp index 0d0b19f089..01e95027f5 100644 --- a/include/openPMD/IO/AbstractIOHandlerHelper.hpp +++ b/include/openPMD/IO/AbstractIOHandlerHelper.hpp @@ -50,7 +50,7 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension, + std::string const &originalExtension, MPI_Comm comm, JSON options, std::string const &pathAsItWasSpecifiedInTheConstructor); @@ -77,7 +77,7 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension, + std::string const &originalExtension, JSON options, std::string const &pathAsItWasSpecifiedInTheConstructor); @@ -86,5 +86,5 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension); + std::string const &originalExtension); } // namespace openPMD diff --git a/include/openPMD/IO/DummyIOHandler.hpp b/include/openPMD/IO/DummyIOHandler.hpp index 7cd4123699..bc2340e13c 100644 --- a/include/openPMD/IO/DummyIOHandler.hpp +++ b/include/openPMD/IO/DummyIOHandler.hpp @@ -34,7 +34,7 @@ namespace openPMD class DummyIOHandler : public AbstractIOHandler { public: - DummyIOHandler(std::string, Access); + DummyIOHandler(std::string const &, Access); ~DummyIOHandler() override = default; /** No-op consistent with the IOHandler interface to enable library use diff --git a/include/openPMD/ReadIterations.hpp b/include/openPMD/ReadIterations.hpp index 35f2f740ce..f55b810353 100644 --- a/include/openPMD/ReadIterations.hpp +++ b/include/openPMD/ReadIterations.hpp @@ -170,7 +170,7 @@ class ReadIterations std::optional m_parsePreference; ReadIterations( - Series, + Series const &, Access, std::optional parsePreference); diff --git a/include/openPMD/backend/Attributable.hpp b/include/openPMD/backend/Attributable.hpp index db7aec37de..2b45ac0e45 100644 --- a/include/openPMD/backend/Attributable.hpp +++ b/include/openPMD/backend/Attributable.hpp @@ -253,7 +253,7 @@ OPENPMD_protected Iteration &containingIteration(); /** @} */ - void seriesFlush(internal::FlushParams); + void seriesFlush(internal::FlushParams const &); void flushAttributes(internal::FlushParams const &); diff --git a/include/openPMD/backend/Writable.hpp b/include/openPMD/backend/Writable.hpp index 7aeead3dfe..5e1272317e 100644 --- a/include/openPMD/backend/Writable.hpp +++ b/include/openPMD/backend/Writable.hpp @@ -119,7 +119,7 @@ class Writable final OPENPMD_private // clang-format on - void seriesFlush(internal::FlushParams); + void seriesFlush(internal::FlushParams const &); /* * These members need to be shared pointers since distinct instances of * Writable may share them. diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 027d884a0d..416bed5c86 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -3396,16 +3396,16 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, openPMD::Access at, MPI_Comm comm, - json::TracingJSON options, - std::string engineType, - std::string specifiedExtension) - : AbstractIOHandler(std::move(path), at, comm) + json::TracingJSON const &options, + std::string const &engineType, + std::string const &specifiedExtension) + : AbstractIOHandler(path, at, comm) , m_impl{ this, comm, - std::move(options), - std::move(engineType), - std::move(specifiedExtension)} + options, + engineType, + specifiedExtension} {} #endif @@ -3413,15 +3413,15 @@ ADIOS2IOHandler::ADIOS2IOHandler( ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, Access at, - json::TracingJSON options, - std::string engineType, - std::string specifiedExtension) + json::TracingJSON const &options, + std::string const &engineType, + std::string const &specifiedExtension) : AbstractIOHandler(path, at) , m_impl{ this, - std::move(options), - std::move(engineType), - std::move(specifiedExtension)} + options, + engineType, + specifiedExtension} {} std::future @@ -3437,9 +3437,9 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, Access at, MPI_Comm comm, - json::TracingJSON, - std::string, - std::string) + json::TracingJSON const&, + std::string const&, + std::string const&) : AbstractIOHandler(path, at, comm) {} @@ -3448,10 +3448,10 @@ ADIOS2IOHandler::ADIOS2IOHandler( ADIOS2IOHandler::ADIOS2IOHandler( std::string const &path, Access at, - json::TracingJSON, - std::string, - std::string) - : AbstractIOHandler(std::move(path), at) + json::TracingJSON const&, + std::string const&, + std::string const&) + : AbstractIOHandler(path, at) {} std::future ADIOS2IOHandler::flush(internal::ParsedFlushParams &) diff --git a/src/IO/AbstractIOHandlerHelper.cpp b/src/IO/AbstractIOHandlerHelper.cpp index e7125a201c..aaf1e3da5f 100644 --- a/src/IO/AbstractIOHandlerHelper.cpp +++ b/src/IO/AbstractIOHandlerHelper.cpp @@ -68,8 +68,7 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension, - + std::string const &originalExtension, MPI_Comm comm, json::TracingJSON options, std::string const &pathAsItWasSpecifiedInTheConstructor) @@ -88,7 +87,7 @@ std::unique_ptr createIOHandler( comm, std::move(options), "file", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_BP4: return constructIOHandler( "ADIOS2", @@ -97,7 +96,7 @@ std::unique_ptr createIOHandler( comm, std::move(options), "bp4", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_BP5: return constructIOHandler( "ADIOS2", @@ -106,7 +105,7 @@ std::unique_ptr createIOHandler( comm, std::move(options), "bp5", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_SST: return constructIOHandler( "ADIOS2", @@ -115,7 +114,7 @@ std::unique_ptr createIOHandler( comm, std::move(options), "sst", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_SSC: return constructIOHandler( "ADIOS2", @@ -124,7 +123,7 @@ std::unique_ptr createIOHandler( comm, std::move(options), "ssc", - std::move(originalExtension)); + originalExtension); case Format::JSON: throw error::WrongAPIUsage( "JSON backend not available in parallel openPMD."); @@ -142,7 +141,7 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension, + std::string const &originalExtension, json::TracingJSON options, std::string const &pathAsItWasSpecifiedInTheConstructor) { @@ -159,7 +158,7 @@ std::unique_ptr createIOHandler( access, std::move(options), "file", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_BP4: return constructIOHandler( "ADIOS2", @@ -167,7 +166,7 @@ std::unique_ptr createIOHandler( access, std::move(options), "bp4", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_BP5: return constructIOHandler( "ADIOS2", @@ -175,7 +174,7 @@ std::unique_ptr createIOHandler( access, std::move(options), "bp5", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_SST: return constructIOHandler( "ADIOS2", @@ -183,7 +182,7 @@ std::unique_ptr createIOHandler( access, std::move(options), "sst", - std::move(originalExtension)); + originalExtension); case Format::ADIOS2_SSC: return constructIOHandler( "ADIOS2", @@ -191,7 +190,7 @@ std::unique_ptr createIOHandler( access, std::move(options), "ssc", - std::move(originalExtension)); + originalExtension); case Format::JSON: return constructIOHandler( "JSON", @@ -199,7 +198,7 @@ std::unique_ptr createIOHandler( access, std::move(options), JSONIOHandlerImpl::FileFormat::Json, - std::move(originalExtension)); + originalExtension); case Format::TOML: return constructIOHandler( "JSON", @@ -207,7 +206,7 @@ std::unique_ptr createIOHandler( access, std::move(options), JSONIOHandlerImpl::FileFormat::Toml, - std::move(originalExtension)); + originalExtension); default: throw std::runtime_error( "Unknown file format! Did you specify a file ending? Specified " @@ -220,13 +219,13 @@ std::unique_ptr createIOHandler( std::string const &path, Access access, Format format, - std::string originalExtension) + std::string const &originalExtension) { return createIOHandler( path, access, format, - std::move(originalExtension), + originalExtension, json::TracingJSON(json::ParsedConfig{}), ""); } diff --git a/src/IO/DummyIOHandler.cpp b/src/IO/DummyIOHandler.cpp index 6bc6ec4d64..5de2dda787 100644 --- a/src/IO/DummyIOHandler.cpp +++ b/src/IO/DummyIOHandler.cpp @@ -25,8 +25,8 @@ namespace openPMD { -DummyIOHandler::DummyIOHandler(std::string path, Access at) - : AbstractIOHandler(std::move(path), at) +DummyIOHandler::DummyIOHandler(std::string const &path, Access at) + : AbstractIOHandler(path, at) {} void DummyIOHandler::enqueue(IOTask const &) diff --git a/src/ReadIterations.cpp b/src/ReadIterations.cpp index afa6d8b1af..7bc6d2c453 100644 --- a/src/ReadIterations.cpp +++ b/src/ReadIterations.cpp @@ -115,7 +115,7 @@ SeriesIterator::SeriesIterator( : m_data{std::make_shared>(std::in_place)} { auto &data = get(); - data.parsePreference = std::move(parsePreference); + data.parsePreference = parsePreference; /* * Since the iterator is stored in * internal::SeriesData::m_sharedStatefulIterator, @@ -613,7 +613,7 @@ SeriesIterator SeriesIterator::end() } ReadIterations::ReadIterations( - Series series, + Series const &series, Access access, std::optional parsePreference) : m_series(series), m_parsePreference(parsePreference) diff --git a/src/Series.cpp b/src/Series.cpp index 8010b11ed3..e6361ee7d2 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -539,11 +539,11 @@ namespace } int autoDetectPadding( - std::function isPartOfSeries, + std::function const &isPartOfSeries, std::string const &directory) { return autoDetectPadding( - std::move(isPartOfSeries), + isPartOfSeries, directory, [](Series::IterationIndex_t index, std::string const &filename) { (void)index; @@ -1020,7 +1020,7 @@ void Series::readFileBased() series.m_filenameExtension); int padding = autoDetectPadding( - std::move(isPartOfSeries), + isPartOfSeries, IOHandler()->directory, // foreach found file with `filename` and `index`: [&series](IterationIndex_t index, std::string const &filename) { diff --git a/src/backend/Attributable.cpp b/src/backend/Attributable.cpp index 66083362ff..52ddda28d3 100644 --- a/src/backend/Attributable.cpp +++ b/src/backend/Attributable.cpp @@ -207,9 +207,9 @@ auto Attributable::myPath() const -> MyPath return res; } -void Attributable::seriesFlush(internal::FlushParams flushParams) +void Attributable::seriesFlush(internal::FlushParams const &flushParams) { - writable().seriesFlush(std::move(flushParams)); + writable().seriesFlush(flushParams); } void Attributable::flushAttributes(internal::FlushParams const &flushParams) diff --git a/src/backend/Writable.cpp b/src/backend/Writable.cpp index dfac17c33d..0acd21d92a 100644 --- a/src/backend/Writable.cpp +++ b/src/backend/Writable.cpp @@ -47,14 +47,14 @@ void Writable::seriesFlush(std::string backendConfig) seriesFlush({FlushLevel::UserFlush, std::move(backendConfig)}); } -void Writable::seriesFlush(internal::FlushParams flushParams) +void Writable::seriesFlush(internal::FlushParams const &flushParams) { auto series = Attributable({attributable, [](auto const *) {}}).retrieveSeries(); series.flush_impl( series.iterations.begin(), series.iterations.end(), - std::move(flushParams)); + flushParams); } } // namespace openPMD diff --git a/src/binding/python/Dataset.cpp b/src/binding/python/Dataset.cpp index 63965ba6de..656cd59ea8 100644 --- a/src/binding/python/Dataset.cpp +++ b/src/binding/python/Dataset.cpp @@ -32,9 +32,9 @@ void init_Dataset(py::module &m) .def(py::init(), py::arg("dtype"), py::arg("extent")) .def(py::init(), py::arg("extent")) .def( - py::init([](py::dtype dt, Extent e) { + py::init([](py::dtype dt, Extent const &e) { auto const d = dtype_from_numpy(std::move(dt)); - return new Dataset{d, std::move(e)}; + return new Dataset{d, e}; }), py::arg("dtype"), py::arg("extent")) @@ -44,9 +44,9 @@ void init_Dataset(py::module &m) py::arg("extent"), py::arg("options")) .def( - py::init([](py::dtype dt, Extent e, std::string options) { + py::init([](py::dtype dt, Extent const &e, std::string options) { auto const d = dtype_from_numpy(std::move(dt)); - return new Dataset{d, std::move(e), std::move(options)}; + return new Dataset{d, e, std::move(options)}; }), py::arg("dtype"), py::arg("extent"), From 8e2c236adb23febf28e1dd32f671344597ed2eca Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 4 Oct 2023 11:38:55 +0200 Subject: [PATCH 05/15] enforce east const --- include/openPMD/Error.hpp | 4 ++-- src/Error.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openPMD/Error.hpp b/include/openPMD/Error.hpp index 70aca03f87..1e5cf69832 100644 --- a/include/openPMD/Error.hpp +++ b/include/openPMD/Error.hpp @@ -51,7 +51,7 @@ namespace error public: std::string backend; OperationUnsupportedInBackend( - std::string backend_in, const std::string &what); + std::string backend_in, std::string const &what); }; /** @@ -63,7 +63,7 @@ namespace error class WrongAPIUsage : public Error { public: - WrongAPIUsage(const std::string &what); + WrongAPIUsage(std::string const &what); }; class BackendConfigSchema : public Error diff --git a/src/Error.cpp b/src/Error.cpp index 2d4a20032d..f2e27a0213 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -12,7 +12,7 @@ const char *Error::what() const noexcept namespace error { OperationUnsupportedInBackend::OperationUnsupportedInBackend( - std::string backend_in, const std::string &what) + std::string backend_in, std::string const &what) : Error("Operation unsupported in " + backend_in + ": " + what) , backend{std::move(backend_in)} {} @@ -23,7 +23,7 @@ namespace error throw OperationUnsupportedInBackend(std::move(backend), what); } - WrongAPIUsage::WrongAPIUsage(const std::string &what) + WrongAPIUsage::WrongAPIUsage(std::string const &what) : Error("Wrong API usage: " + what) {} From 36e49d1f24e9729671e7c827d10a66c53d4c21d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:36:17 +0000 Subject: [PATCH 06/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- include/openPMD/Error.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openPMD/Error.hpp b/include/openPMD/Error.hpp index 1e5cf69832..3e516e16ec 100644 --- a/include/openPMD/Error.hpp +++ b/include/openPMD/Error.hpp @@ -63,7 +63,7 @@ namespace error class WrongAPIUsage : public Error { public: - WrongAPIUsage(std::string const &what); + WrongAPIUsage(std::string const &what); }; class BackendConfigSchema : public Error From dd8dabe2fd0fbd0c532686f5147c48a676cd6425 Mon Sep 17 00:00:00 2001 From: lucafedeli88 Date: Thu, 5 Oct 2023 03:56:04 +0200 Subject: [PATCH 07/15] fix bug --- test/SerialIOTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 467495e35d..af78dfa23b 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -6421,7 +6421,7 @@ void deferred_parsing(std::string const &extension) } infix = padding.append(infix); std::ofstream file; - file.open(basename.append(infix).append(".").append(extension)); + file.open(std::string(basename).append(infix).append(".").append(extension)); file.close(); } } From 36332037861f919986df15d6e4038e5c7e4af747 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:56:16 +0000 Subject: [PATCH 08/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- test/SerialIOTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index af78dfa23b..7dda452039 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -6421,7 +6421,8 @@ void deferred_parsing(std::string const &extension) } infix = padding.append(infix); std::ofstream file; - file.open(std::string(basename).append(infix).append(".").append(extension)); + file.open(std::string(basename).append(infix).append(".").append( + extension)); file.close(); } } From 0d9f2f4028de97453e0387ddb79c16ea59713559 Mon Sep 17 00:00:00 2001 From: lucafedeli88 Date: Thu, 5 Oct 2023 04:01:51 +0200 Subject: [PATCH 09/15] cleaning --- src/IO/ADIOS/ADIOS2IOHandler.cpp | 2 +- src/auxiliary/Filesystem.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index b616fd70e7..7c32e77378 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -1354,7 +1354,7 @@ void ADIOS2IOHandlerImpl::closePath( for (auto const &attr : fileData.availableAttributesPrefixed(positionString)) { - fileData.m_IO.RemoveAttribute(positionString.append("/").append(attr)); + fileData.m_IO.RemoveAttribute(std::string(positionString).append("/").append(attr)); } } diff --git a/src/auxiliary/Filesystem.cpp b/src/auxiliary/Filesystem.cpp index f7ccbeb0e1..cce80b9d17 100644 --- a/src/auxiliary/Filesystem.cpp +++ b/src/auxiliary/Filesystem.cpp @@ -153,8 +153,7 @@ bool remove_directory(std::string const &path) for (auto const &entry : list_directory(path)) { auto partialPath = path; - partialPath = partialPath.append(std::string(1, directory_separator)) - .append(entry); + partialPath.append(std::string(1, directory_separator)).append(entry); if (directory_exists(partialPath)) success &= remove_directory(partialPath); else if (file_exists(partialPath)) From 99a98f7d0bfbab37caf99eae2c34444d5fbdf3c2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 02:02:56 +0000 Subject: [PATCH 10/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/IO/ADIOS/ADIOS2IOHandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 7c32e77378..94dc799dc0 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -1354,7 +1354,8 @@ void ADIOS2IOHandlerImpl::closePath( for (auto const &attr : fileData.availableAttributesPrefixed(positionString)) { - fileData.m_IO.RemoveAttribute(std::string(positionString).append("/").append(attr)); + fileData.m_IO.RemoveAttribute( + std::string(positionString).append("/").append(attr)); } } From def0ed90c84876b4f43bc805f943a053df7034dc Mon Sep 17 00:00:00 2001 From: lucafedeli88 Date: Thu, 5 Oct 2023 10:47:17 +0200 Subject: [PATCH 11/15] remove unused variable --- test/SerialIOTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 7dda452039..2197ac7194 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -5806,7 +5806,6 @@ void variableBasedParticleData() for (size_t i = 0; i < 3; ++i) { - std::string const &dim = dimensions[i]; Extent const &extent = extents[i]; auto chunk = loadedChunks[i]; for (size_t j = 0; j < extent[0]; ++j) From d216aad0278b26591c58fa37e6c5b194e7157db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 20 Oct 2023 17:33:12 +0200 Subject: [PATCH 12/15] Fix some corrections that were too ambitious --- include/openPMD/Dataset.hpp | 4 +- include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp | 18 ++-- .../openPMD/IO/AbstractIOHandlerHelper.hpp | 12 +-- include/openPMD/IO/DummyIOHandler.hpp | 2 +- include/openPMD/IO/HDF5/HDF5IOHandler.hpp | 2 +- .../openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp | 2 +- include/openPMD/IO/InvalidatableFile.hpp | 4 +- include/openPMD/IO/JSON/JSONIOHandler.hpp | 2 +- include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp | 2 +- include/openPMD/ReadIterations.hpp | 2 +- include/openPMD/Series.hpp | 8 +- src/Dataset.cpp | 14 ++-- src/IO/ADIOS/ADIOS2IOHandler.cpp | 82 ++++++++++++------- src/IO/AbstractIOHandlerHelper.cpp | 64 +++++++-------- src/IO/DummyIOHandler.cpp | 4 +- src/IO/HDF5/HDF5IOHandler.cpp | 14 +++- src/IO/HDF5/ParallelHDF5IOHandler.cpp | 22 +++-- src/IO/InvalidatableFile.cpp | 11 ++- src/IO/JSON/JSONIOHandler.cpp | 4 +- src/IO/JSON/JSONIOHandlerImpl.cpp | 11 ++- src/ReadIterations.cpp | 4 +- src/Series.cpp | 4 +- src/WriteIterations.cpp | 4 +- src/version.cpp | 6 +- 24 files changed, 175 insertions(+), 127 deletions(-) diff --git a/include/openPMD/Dataset.hpp b/include/openPMD/Dataset.hpp index 68de3b5879..8757a3cf0a 100644 --- a/include/openPMD/Dataset.hpp +++ b/include/openPMD/Dataset.hpp @@ -37,7 +37,7 @@ class Dataset friend class RecordComponent; public: - Dataset(Datatype, Extent const &, std::string options = "{}"); + Dataset(Datatype, Extent, std::string options = "{}"); /** * @brief Constructor that sets the datatype to undefined. @@ -45,7 +45,7 @@ class Dataset * Helpful for resizing datasets, since datatypes need not be given twice. * */ - Dataset(Extent const &); + Dataset(Extent); Dataset &extend(Extent newExtent); diff --git a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp index f82564c3ff..e63c6a493b 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp @@ -466,7 +466,7 @@ namespace detail ADIOS2IOHandlerImpl &, adios2::IO &IO, std::string name, - std::shared_ptr const &resource); + Attribute::resource &resource); template static Datatype call(Params &&...); @@ -1196,21 +1196,21 @@ class ADIOS2IOHandler : public AbstractIOHandler #if openPMD_HAVE_MPI ADIOS2IOHandler( - std::string const &path, + std::string path, Access, MPI_Comm, - json::TracingJSON const &options, - std::string const &engineType, - std::string const &specifiedExtension); + json::TracingJSON options, + std::string engineType, + std::string specifiedExtension); #endif ADIOS2IOHandler( - std::string const &path, + std::string path, Access, - json::TracingJSON const &options, - std::string const &engineType, - std::string const &specifiedExtension); + json::TracingJSON options, + std::string engineType, + std::string specifiedExtension); std::string backendName() const override { diff --git a/include/openPMD/IO/AbstractIOHandlerHelper.hpp b/include/openPMD/IO/AbstractIOHandlerHelper.hpp index 01e95027f5..a5ce7a39be 100644 --- a/include/openPMD/IO/AbstractIOHandlerHelper.hpp +++ b/include/openPMD/IO/AbstractIOHandlerHelper.hpp @@ -47,10 +47,10 @@ namespace openPMD */ template std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension, + std::string originalExtension, MPI_Comm comm, JSON options, std::string const &pathAsItWasSpecifiedInTheConstructor); @@ -74,17 +74,17 @@ std::unique_ptr createIOHandler( */ template std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension, + std::string originalExtension, JSON options, std::string const &pathAsItWasSpecifiedInTheConstructor); // version without configuration to use in AuxiliaryTest std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension); + std::string originalExtension); } // namespace openPMD diff --git a/include/openPMD/IO/DummyIOHandler.hpp b/include/openPMD/IO/DummyIOHandler.hpp index bc2340e13c..7cd4123699 100644 --- a/include/openPMD/IO/DummyIOHandler.hpp +++ b/include/openPMD/IO/DummyIOHandler.hpp @@ -34,7 +34,7 @@ namespace openPMD class DummyIOHandler : public AbstractIOHandler { public: - DummyIOHandler(std::string const &, Access); + DummyIOHandler(std::string, Access); ~DummyIOHandler() override = default; /** No-op consistent with the IOHandler interface to enable library use diff --git a/include/openPMD/IO/HDF5/HDF5IOHandler.hpp b/include/openPMD/IO/HDF5/HDF5IOHandler.hpp index da335de758..e81996b389 100644 --- a/include/openPMD/IO/HDF5/HDF5IOHandler.hpp +++ b/include/openPMD/IO/HDF5/HDF5IOHandler.hpp @@ -34,7 +34,7 @@ class HDF5IOHandlerImpl; class HDF5IOHandler : public AbstractIOHandler { public: - HDF5IOHandler(std::string const &path, Access, json::TracingJSON config); + HDF5IOHandler(std::string path, Access, json::TracingJSON config); ~HDF5IOHandler() override; std::string backendName() const override diff --git a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp index 8bc7142b2f..cd951be5d2 100644 --- a/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp +++ b/include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp @@ -37,7 +37,7 @@ class ParallelHDF5IOHandler : public AbstractIOHandler public: #if openPMD_HAVE_MPI ParallelHDF5IOHandler( - std::string const &path, Access, MPI_Comm, json::TracingJSON config); + std::string path, Access, MPI_Comm, json::TracingJSON config); #else ParallelHDF5IOHandler( std::string const &path, Access, json::TracingJSON config); diff --git a/include/openPMD/IO/InvalidatableFile.hpp b/include/openPMD/IO/InvalidatableFile.hpp index 9a6d3fab3d..31c9fd3fcc 100644 --- a/include/openPMD/IO/InvalidatableFile.hpp +++ b/include/openPMD/IO/InvalidatableFile.hpp @@ -42,7 +42,7 @@ namespace openPMD */ struct InvalidatableFile { - explicit InvalidatableFile(std::string const &s); + explicit InvalidatableFile(std::string s); InvalidatableFile() = default; @@ -60,7 +60,7 @@ struct InvalidatableFile bool valid() const; - InvalidatableFile &operator=(std::string const &s); + InvalidatableFile &operator=(std::string s); bool operator==(InvalidatableFile const &f) const; diff --git a/include/openPMD/IO/JSON/JSONIOHandler.hpp b/include/openPMD/IO/JSON/JSONIOHandler.hpp index 923c032853..7fdea5b6f0 100644 --- a/include/openPMD/IO/JSON/JSONIOHandler.hpp +++ b/include/openPMD/IO/JSON/JSONIOHandler.hpp @@ -32,7 +32,7 @@ class JSONIOHandler : public AbstractIOHandler JSONIOHandler( std::string const &path, Access at, - openPMD::json::TracingJSON const &config, + openPMD::json::TracingJSON config, JSONIOHandlerImpl::FileFormat, std::string originalExtension); diff --git a/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp b/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp index 07b25b030e..5ce9d057c3 100644 --- a/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp +++ b/include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp @@ -163,7 +163,7 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl explicit JSONIOHandlerImpl( AbstractIOHandler *, - openPMD::json::TracingJSON const &config, + openPMD::json::TracingJSON config, FileFormat, std::string originalExtension); diff --git a/include/openPMD/ReadIterations.hpp b/include/openPMD/ReadIterations.hpp index f55b810353..35f2f740ce 100644 --- a/include/openPMD/ReadIterations.hpp +++ b/include/openPMD/ReadIterations.hpp @@ -170,7 +170,7 @@ class ReadIterations std::optional m_parsePreference; ReadIterations( - Series const &, + Series, Access, std::optional parsePreference); diff --git a/include/openPMD/Series.hpp b/include/openPMD/Series.hpp index be74a6ff18..094ed24fbf 100644 --- a/include/openPMD/Series.hpp +++ b/include/openPMD/Series.hpp @@ -241,7 +241,13 @@ class Series : public Attributable Access at, std::string const &options = "{}"); - virtual ~Series() = default; + Series(Series const &) = default; + Series(Series &&) = default; + + Series &operator=(Series const &) = default; + Series &operator=(Series &&) = default; + + ~Series() override = default; /** * An unsigned integer type, used to identify Iterations in a Series. diff --git a/src/Dataset.cpp b/src/Dataset.cpp index 565bab0ad3..662bd2d29f 100644 --- a/src/Dataset.cpp +++ b/src/Dataset.cpp @@ -25,14 +25,14 @@ namespace openPMD { -Dataset::Dataset(Datatype d, const Extent &e, std::string options_in) - : extent{e} - , dtype{d} - , rank{static_cast(e.size())} - , options{std::move(options_in)} -{} +Dataset::Dataset(Datatype d, Extent e, std::string options_in) + : extent{std::move(e)}, dtype{d}, options{std::move(options_in)} +{ + // avoid initialization order issues + rank = static_cast(extent.size()); +} -Dataset::Dataset(Extent const &e) : Dataset(Datatype::UNDEFINED, e) +Dataset::Dataset(Extent e) : Dataset(Datatype::UNDEFINED, std::move(e)) {} Dataset &Dataset::extend(Extent newExtents) diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 94dc799dc0..2263eb3079 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -1111,7 +1111,7 @@ void ADIOS2IOHandlerImpl::readAttribute( } Datatype ret = switchType( - type, *this, ba.m_IO, name, parameters.resource); + type, *this, ba.m_IO, name, *parameters.resource); *parameters.dtype = ret; } @@ -1615,7 +1615,7 @@ namespace detail ADIOS2IOHandlerImpl &impl, adios2::IO &IO, std::string name, - std::shared_ptr const &resource) + Attribute::resource &resource) { (void)impl; /* @@ -1653,11 +1653,11 @@ namespace detail auto meta = IO.InquireAttribute(metaAttr); if (meta.Data().size() == 1 && meta.Data()[0] == 1) { - *resource = bool_repr::fromRep(attr.Data()[0]); + resource = bool_repr::fromRep(attr.Data()[0]); return determineDatatype(); } } - *resource = attr.Data()[0]; + resource = attr.Data()[0]; } else if constexpr (IsUnsupportedComplex_v) { @@ -1674,7 +1674,7 @@ namespace detail "[ADIOS2] Internal error: Failed reading attribute '" + name + "'."); } - *resource = attr.Data(); + resource = attr.Data(); } else if constexpr (auxiliary::IsArray_v) { @@ -1691,7 +1691,7 @@ namespace detail { res[i] = data[i]; } - *resource = res; + resource = res; } else if constexpr (std::is_same_v) { @@ -1707,7 +1707,7 @@ namespace detail "[ADIOS2] Internal error: Failed reading attribute '" + name + "'."); } - *resource = attr.Data()[0]; + resource = attr.Data()[0]; } return determineDatatype(); @@ -3394,26 +3394,35 @@ namespace detail #if openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string const &path, + std::string path, openPMD::Access at, MPI_Comm comm, - json::TracingJSON const &options, - std::string const &engineType, - std::string const &specifiedExtension) - : AbstractIOHandler(path, at, comm) - , m_impl{this, comm, options, engineType, specifiedExtension} + json::TracingJSON options, + std::string engineType, + std::string specifiedExtension) + : AbstractIOHandler(std::move(path), at, comm) + , m_impl{ + this, + comm, + std::move(options), + std::move(engineType), + std::move(specifiedExtension)} {} #endif ADIOS2IOHandler::ADIOS2IOHandler( - std::string const &path, + std::string path, Access at, - json::TracingJSON const &options, - std::string const &engineType, - std::string const &specifiedExtension) - : AbstractIOHandler(path, at) - , m_impl{this, options, engineType, specifiedExtension} + json::TracingJSON options, + std::string engineType, + std::string specifiedExtension) + : AbstractIOHandler(std::move(path), at) + , m_impl{ + this, + std::move(options), + std::move(engineType), + std::move(specifiedExtension)} {} std::future @@ -3424,27 +3433,38 @@ ADIOS2IOHandler::flush(internal::ParsedFlushParams &flushParams) #else // openPMD_HAVE_ADIOS2 +namespace detail +{ + template + void forget(Args...) + {} +} // namespace detail + #if openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string const &path, + std::string path, Access at, MPI_Comm comm, - json::TracingJSON const &, - std::string const &, - std::string const &) - : AbstractIOHandler(path, at, comm) -{} + json::TracingJSON a, + std::string b, + std::string c) + : AbstractIOHandler(std::move(path), at, comm) +{ + detail::forget(a, b, c); +} #endif // openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( - std::string const &path, + std::string path, Access at, - json::TracingJSON const &, - std::string const &, - std::string const &) - : AbstractIOHandler(path, at) -{} + json::TracingJSON a, + std::string b, + std::string c) + : AbstractIOHandler(std::move(path), at) +{ + detail::forget(std::move(a), std::move(b), std::move(c)); +} std::future ADIOS2IOHandler::flush(internal::ParsedFlushParams &) { diff --git a/src/IO/AbstractIOHandlerHelper.cpp b/src/IO/AbstractIOHandlerHelper.cpp index aaf1e3da5f..699dfd3619 100644 --- a/src/IO/AbstractIOHandlerHelper.cpp +++ b/src/IO/AbstractIOHandlerHelper.cpp @@ -65,10 +65,10 @@ namespace #if openPMD_HAVE_MPI template <> std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension, + std::string originalExtension, MPI_Comm comm, json::TracingJSON options, std::string const &pathAsItWasSpecifiedInTheConstructor) @@ -82,48 +82,48 @@ std::unique_ptr createIOHandler( case Format::ADIOS2_BP: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, comm, std::move(options), "file", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_BP4: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, comm, std::move(options), "bp4", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_BP5: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, comm, std::move(options), "bp5", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_SST: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, comm, std::move(options), "sst", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_SSC: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, comm, std::move(options), "ssc", - originalExtension); + std::move(originalExtension)); case Format::JSON: throw error::WrongAPIUsage( "JSON backend not available in parallel openPMD."); @@ -138,10 +138,10 @@ std::unique_ptr createIOHandler( template <> std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension, + std::string originalExtension, json::TracingJSON options, std::string const &pathAsItWasSpecifiedInTheConstructor) { @@ -154,59 +154,59 @@ std::unique_ptr createIOHandler( case Format::ADIOS2_BP: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, std::move(options), "file", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_BP4: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, std::move(options), "bp4", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_BP5: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, std::move(options), "bp5", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_SST: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, std::move(options), "sst", - originalExtension); + std::move(originalExtension)); case Format::ADIOS2_SSC: return constructIOHandler( "ADIOS2", - path, + std::move(path), access, std::move(options), "ssc", - originalExtension); + std::move(originalExtension)); case Format::JSON: return constructIOHandler( "JSON", - path, + std::move(path), access, std::move(options), JSONIOHandlerImpl::FileFormat::Json, - originalExtension); + std::move(originalExtension)); case Format::TOML: return constructIOHandler( "JSON", - path, + std::move(path), access, std::move(options), JSONIOHandlerImpl::FileFormat::Toml, - originalExtension); + std::move(originalExtension)); default: throw std::runtime_error( "Unknown file format! Did you specify a file ending? Specified " @@ -216,16 +216,16 @@ std::unique_ptr createIOHandler( } std::unique_ptr createIOHandler( - std::string const &path, + std::string path, Access access, Format format, - std::string const &originalExtension) + std::string originalExtension) { return createIOHandler( - path, + std::move(path), access, format, - originalExtension, + std::move(originalExtension), json::TracingJSON(json::ParsedConfig{}), ""); } diff --git a/src/IO/DummyIOHandler.cpp b/src/IO/DummyIOHandler.cpp index 5de2dda787..6bc6ec4d64 100644 --- a/src/IO/DummyIOHandler.cpp +++ b/src/IO/DummyIOHandler.cpp @@ -25,8 +25,8 @@ namespace openPMD { -DummyIOHandler::DummyIOHandler(std::string const &path, Access at) - : AbstractIOHandler(path, at) +DummyIOHandler::DummyIOHandler(std::string path, Access at) + : AbstractIOHandler(std::move(path), at) {} void DummyIOHandler::enqueue(IOTask const &) diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index 1259a237b8..c052ce3f95 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -2802,8 +2802,8 @@ HDF5IOHandlerImpl::getFile(Writable *writable) #if openPMD_HAVE_HDF5 HDF5IOHandler::HDF5IOHandler( - std::string const &path, Access at, json::TracingJSON config) - : AbstractIOHandler(path, at) + std::string path, Access at, json::TracingJSON config) + : AbstractIOHandler(std::move(path), at) , m_impl{new HDF5IOHandlerImpl(this, std::move(config))} {} @@ -2814,10 +2814,18 @@ std::future HDF5IOHandler::flush(internal::ParsedFlushParams &) return m_impl->flush(); } #else +namespace detail +{ + template + void forget(T) + {} +} // namespace detail + HDF5IOHandler::HDF5IOHandler( - std::string const &path, Access at, json::TracingJSON /* config */) + std::string path, Access at, json::TracingJSON config) : AbstractIOHandler(std::move(path), at) { + detail::forget(std::move(config)); throw std::runtime_error("openPMD-api built without HDF5 support"); } diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index dcc8676f8b..5f7fa8edcb 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -47,8 +47,8 @@ namespace openPMD #endif ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string const &path, Access at, MPI_Comm comm, json::TracingJSON config) - : AbstractIOHandler(path, at, comm) + std::string path, Access at, MPI_Comm comm, json::TracingJSON config) + : AbstractIOHandler(std::move(path), at, comm) , m_impl{new ParallelHDF5IOHandlerImpl(this, comm, std::move(config))} {} @@ -180,21 +180,27 @@ ParallelHDF5IOHandlerImpl::~ParallelHDF5IOHandlerImpl() } } #else +namespace detail +{ + template + void forget(T) + {} +} // namespace detail + #if openPMD_HAVE_MPI ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string const &path, - Access at, - MPI_Comm comm, - json::TracingJSON /* config */) - : AbstractIOHandler(path, at, comm) + std::string path, Access at, MPI_Comm comm, json::TracingJSON config) + : AbstractIOHandler(std::move(path), at, comm) { + detail::forget(std::move(config)); throw std::runtime_error("openPMD-api built without HDF5 support"); } #else ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string const &path, Access at, json::TracingJSON /* config */) + std::string const &path, Access at, json::TracingJSON config) : AbstractIOHandler(path, at) { + detail::forget(std::move(config)); throw std::runtime_error( "openPMD-api built without parallel support and without HDF5 support"); } diff --git a/src/IO/InvalidatableFile.cpp b/src/IO/InvalidatableFile.cpp index 4825f91789..4d512f8064 100644 --- a/src/IO/InvalidatableFile.cpp +++ b/src/IO/InvalidatableFile.cpp @@ -21,8 +21,8 @@ #include "openPMD/IO/InvalidatableFile.hpp" -openPMD::InvalidatableFile::InvalidatableFile(std::string const &s) - : fileState{std::make_shared(s)} +openPMD::InvalidatableFile::InvalidatableFile(std::string s) + : fileState{std::make_shared(std::move(s))} {} void openPMD::InvalidatableFile::invalidate() @@ -35,16 +35,15 @@ bool openPMD::InvalidatableFile::valid() const return fileState->valid; } -openPMD::InvalidatableFile & -openPMD::InvalidatableFile::operator=(std::string const &s) +openPMD::InvalidatableFile &openPMD::InvalidatableFile::operator=(std::string s) { if (fileState) { - fileState->name = s; + fileState->name = std::move(s); } else { - fileState = std::make_shared(s); + fileState = std::make_shared(std::move(s)); } return *this; } diff --git a/src/IO/JSON/JSONIOHandler.cpp b/src/IO/JSON/JSONIOHandler.cpp index 7a0e7f1abb..041b236340 100644 --- a/src/IO/JSON/JSONIOHandler.cpp +++ b/src/IO/JSON/JSONIOHandler.cpp @@ -28,11 +28,11 @@ JSONIOHandler::~JSONIOHandler() = default; JSONIOHandler::JSONIOHandler( std::string const &path, Access at, - openPMD::json::TracingJSON const &jsonCfg, + openPMD::json::TracingJSON jsonCfg, JSONIOHandlerImpl::FileFormat format, std::string originalExtension) : AbstractIOHandler{path, at} - , m_impl{this, jsonCfg, format, std::move(originalExtension)} + , m_impl{this, std::move(jsonCfg), format, std::move(originalExtension)} {} std::future JSONIOHandler::flush(internal::ParsedFlushParams &) diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index 6cd4a5c805..3a77e71ec5 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -122,9 +122,16 @@ namespace } } // namespace +namespace detail +{ + template + void forget(T) + {} +} // namespace detail + JSONIOHandlerImpl::JSONIOHandlerImpl( AbstractIOHandler *handler, - openPMD::json::TracingJSON const &config, + openPMD::json::TracingJSON config, FileFormat format, std::string originalExtension) : AbstractIOHandlerImpl(handler) @@ -132,7 +139,7 @@ JSONIOHandlerImpl::JSONIOHandlerImpl( , m_originalExtension{std::move(originalExtension)} { // Currently unused - (void)config; + detail::forget(std::move(config)); } JSONIOHandlerImpl::~JSONIOHandlerImpl() = default; diff --git a/src/ReadIterations.cpp b/src/ReadIterations.cpp index 7bc6d2c453..ed31886ffd 100644 --- a/src/ReadIterations.cpp +++ b/src/ReadIterations.cpp @@ -613,10 +613,10 @@ SeriesIterator SeriesIterator::end() } ReadIterations::ReadIterations( - Series const &series, + Series series, Access access, std::optional parsePreference) - : m_series(series), m_parsePreference(parsePreference) + : m_series(std::move(series)), m_parsePreference(parsePreference) { auto &data = m_series.get(); if (access == Access::READ_LINEAR && !data.m_sharedStatefulIterator) diff --git a/src/Series.cpp b/src/Series.cpp index e6361ee7d2..b7c807eb4c 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -2386,7 +2386,9 @@ ReadIterations Series::readIterations() // Use private constructor instead of copy constructor to avoid // object slicing return { - this->m_series, IOHandler()->m_frontendAccess, get().m_parsePreference}; + Series(this->m_series), + IOHandler()->m_frontendAccess, + get().m_parsePreference}; } void Series::parseBase() diff --git a/src/WriteIterations.cpp b/src/WriteIterations.cpp index ba7876e884..0ae7246ae0 100644 --- a/src/WriteIterations.cpp +++ b/src/WriteIterations.cpp @@ -75,7 +75,7 @@ WriteIterations::mapped_type &WriteIterations::operator[](key_type &&key) auto lastIteration_v = lastIteration.value(); if (lastIteration_v.iterationIndex == key) { - return s.iterations.at(key); + return s.iterations.at(std::forward(key)); } else { @@ -83,7 +83,7 @@ WriteIterations::mapped_type &WriteIterations::operator[](key_type &&key) } } s.currentlyOpen = key; - auto &res = s.iterations[key]; + auto &res = s.iterations[std::forward(key)]; if (res.getStepStatus() == StepStatus::NoStep) { try diff --git a/src/version.cpp b/src/version.cpp index 77d870c9e8..6fa0a9ecfa 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -30,7 +30,7 @@ std::string openPMD::getVersion() << OPENPMDAPI_VERSION_PATCH; if (std::string(OPENPMDAPI_VERSION_LABEL).size() > 0) api << "-" << OPENPMDAPI_VERSION_LABEL; - std::string apistr = api.str(); + std::string const apistr = api.str(); return apistr; } @@ -39,7 +39,7 @@ std::string openPMD::getStandard() std::stringstream standard; standard << OPENPMD_STANDARD_MAJOR << "." << OPENPMD_STANDARD_MINOR << "." << OPENPMD_STANDARD_PATCH; - std::string standardstr = standard.str(); + std::string const standardstr = standard.str(); return standardstr; } @@ -49,6 +49,6 @@ std::string openPMD::getStandardMinimum() standardMin << OPENPMD_STANDARD_MIN_MAJOR << "." << OPENPMD_STANDARD_MIN_MINOR << "." << OPENPMD_STANDARD_MIN_PATCH; - std::string standardMinstr = standardMin.str(); + std::string const standardMinstr = standardMin.str(); return standardMinstr; } From d92d69a0fe9620c1706b24e03a1b6f8f07f3cd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 9 Nov 2023 15:55:09 +0100 Subject: [PATCH 13/15] Some little forgotten clang-tidy checks --- src/version.cpp | 9 +++------ test/AuxiliaryTest.cpp | 1 + test/ParallelIOTest.cpp | 3 +-- test/SerialIOTest.cpp | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/version.cpp b/src/version.cpp index 6fa0a9ecfa..c2e8809a32 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -30,8 +30,7 @@ std::string openPMD::getVersion() << OPENPMDAPI_VERSION_PATCH; if (std::string(OPENPMDAPI_VERSION_LABEL).size() > 0) api << "-" << OPENPMDAPI_VERSION_LABEL; - std::string const apistr = api.str(); - return apistr; + return api.str(); } std::string openPMD::getStandard() @@ -39,8 +38,7 @@ std::string openPMD::getStandard() std::stringstream standard; standard << OPENPMD_STANDARD_MAJOR << "." << OPENPMD_STANDARD_MINOR << "." << OPENPMD_STANDARD_PATCH; - std::string const standardstr = standard.str(); - return standardstr; + return standard.str(); } std::string openPMD::getStandardMinimum() @@ -49,6 +47,5 @@ std::string openPMD::getStandardMinimum() standardMin << OPENPMD_STANDARD_MIN_MAJOR << "." << OPENPMD_STANDARD_MIN_MINOR << "." << OPENPMD_STANDARD_MIN_PATCH; - std::string const standardMinstr = standardMin.str(); - return standardMinstr; + return standardMin.str(); } diff --git a/test/AuxiliaryTest.cpp b/test/AuxiliaryTest.cpp index 85d9c7c26d..7cc88f3b65 100644 --- a/test/AuxiliaryTest.cpp +++ b/test/AuxiliaryTest.cpp @@ -64,6 +64,7 @@ TEST_CASE("deref_cast_test", "[auxiliary]") B const value = {123.45}; B const *const ptr = &value; + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) auto const a = deref_dynamic_cast(ptr); auto const &ra = deref_dynamic_cast(ptr); (void)a; diff --git a/test/ParallelIOTest.cpp b/test/ParallelIOTest.cpp index 215ff4f2c9..eb9765375a 100644 --- a/test/ParallelIOTest.cpp +++ b/test/ParallelIOTest.cpp @@ -75,9 +75,8 @@ TEST_CASE("parallel_multi_series_test", "[parallel]") // have multiple serial series alive at the same time for (auto const sn : {1, 2, 3}) { - for (auto const &t : myBackends) + for (auto const &file_ending : myBackends) { - auto const file_ending = t; std::cout << file_ending << std::endl; allSeries.emplace_back( std::string("../samples/parallel_multi_open_test_") diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 2197ac7194..c4e22d894c 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -237,9 +237,8 @@ TEST_CASE("multi_series_test", "[serial]") // have multiple serial series alive at the same time for (auto const sn : {1, 2, 3}) { - for (auto const &t : myfileExtensions) + for (auto const &file_ending : myfileExtensions) { - auto const file_ending = t; std::cout << file_ending << std::endl; allSeries.emplace_back( std::string("../samples/multi_open_test_") From 6aba6b88b4cd02c525d5a4344be1236bb925d820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 9 Nov 2023 16:30:21 +0100 Subject: [PATCH 14/15] Fixes after merging the dev --- test/CoreTest.cpp | 1 + test/SerialIOTest.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/test/CoreTest.cpp b/test/CoreTest.cpp index f6f93e065c..58505ec85f 100644 --- a/test/CoreTest.cpp +++ b/test/CoreTest.cpp @@ -49,6 +49,7 @@ TEST_CASE("attribute_dtype_test", "[core]") REQUIRE(Datatype::CHAR == a.dtype); { // check that copy constructor works + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) [[maybe_unused]] Attribute b = a; } { diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 814d1fef05..52ee3c387a 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -596,7 +596,13 @@ struct NonCopyableDeleter : std::function {} NonCopyableDeleter(NonCopyableDeleter const &) = delete; NonCopyableDeleter &operator=(NonCopyableDeleter const &) = delete; + /* + * MSVC does not recognize these when declaring noexcept and this is + * for a test only anyway. + */ + // NOLINTNEXTLINE(performance-noexcept-move-constructor) NonCopyableDeleter(NonCopyableDeleter &&) = default; + // NOLINTNEXTLINE(performance-noexcept-move-constructor) NonCopyableDeleter &operator=(NonCopyableDeleter &&) = default; }; } // namespace detail From 21ecbc95657990f78095ad7335300d562dcaa1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 10 Nov 2023 09:42:05 +0100 Subject: [PATCH 15/15] Replace auxiliary::forget() with NOLINT comments --- src/IO/ADIOS/ADIOS2IOHandler.cpp | 33 ++++++++++++--------------- src/IO/HDF5/HDF5IOHandler.cpp | 12 ++++------ src/IO/HDF5/ParallelHDF5IOHandler.cpp | 19 ++++++++------- src/IO/JSON/JSONIOHandlerImpl.cpp | 15 +++--------- 4 files changed, 30 insertions(+), 49 deletions(-) diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 2263eb3079..8cddd578a0 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -3433,38 +3433,33 @@ ADIOS2IOHandler::flush(internal::ParsedFlushParams &flushParams) #else // openPMD_HAVE_ADIOS2 -namespace detail -{ - template - void forget(Args...) - {} -} // namespace detail - #if openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( std::string path, Access at, MPI_Comm comm, - json::TracingJSON a, - std::string b, - std::string c) + // NOLINTNEXTLINE(performance-unnecessary-value-param) + json::TracingJSON, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::string, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::string) : AbstractIOHandler(std::move(path), at, comm) -{ - detail::forget(a, b, c); -} +{} #endif // openPMD_HAVE_MPI ADIOS2IOHandler::ADIOS2IOHandler( std::string path, Access at, - json::TracingJSON a, - std::string b, - std::string c) + // NOLINTNEXTLINE(performance-unnecessary-value-param) + json::TracingJSON, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::string, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::string) : AbstractIOHandler(std::move(path), at) -{ - detail::forget(std::move(a), std::move(b), std::move(c)); -} +{} std::future ADIOS2IOHandler::flush(internal::ParsedFlushParams &) { diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index c052ce3f95..e2fa63d9b3 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -2814,18 +2814,14 @@ std::future HDF5IOHandler::flush(internal::ParsedFlushParams &) return m_impl->flush(); } #else -namespace detail -{ - template - void forget(T) - {} -} // namespace detail HDF5IOHandler::HDF5IOHandler( - std::string path, Access at, json::TracingJSON config) + std::string path, + Access at, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [[maybe_unused]] json::TracingJSON config) : AbstractIOHandler(std::move(path), at) { - detail::forget(std::move(config)); throw std::runtime_error("openPMD-api built without HDF5 support"); } diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index 5f7fa8edcb..47a7764480 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -180,27 +180,26 @@ ParallelHDF5IOHandlerImpl::~ParallelHDF5IOHandlerImpl() } } #else -namespace detail -{ - template - void forget(T) - {} -} // namespace detail #if openPMD_HAVE_MPI ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string path, Access at, MPI_Comm comm, json::TracingJSON config) + std::string path, + Access at, + MPI_Comm comm, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [[maybe_unused]] json::TracingJSON config) : AbstractIOHandler(std::move(path), at, comm) { - detail::forget(std::move(config)); throw std::runtime_error("openPMD-api built without HDF5 support"); } #else ParallelHDF5IOHandler::ParallelHDF5IOHandler( - std::string const &path, Access at, json::TracingJSON config) + std::string const &path, + Access at, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [[maybe_unused]] json::TracingJSON config) : AbstractIOHandler(path, at) { - detail::forget(std::move(config)); throw std::runtime_error( "openPMD-api built without parallel support and without HDF5 support"); } diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index 3a77e71ec5..a4e1bb39ab 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -122,25 +122,16 @@ namespace } } // namespace -namespace detail -{ - template - void forget(T) - {} -} // namespace detail - JSONIOHandlerImpl::JSONIOHandlerImpl( AbstractIOHandler *handler, - openPMD::json::TracingJSON config, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [[maybe_unused]] openPMD::json::TracingJSON config, FileFormat format, std::string originalExtension) : AbstractIOHandlerImpl(handler) , m_fileFormat{format} , m_originalExtension{std::move(originalExtension)} -{ - // Currently unused - detail::forget(std::move(config)); -} +{} JSONIOHandlerImpl::~JSONIOHandlerImpl() = default;