diff --git a/dbms/src/Common/CompactArray.h b/dbms/src/Common/CompactArray.h index 3cd47b8013e..5a948b57059 100644 --- a/dbms/src/Common/CompactArray.h +++ b/dbms/src/Common/CompactArray.h @@ -86,7 +86,7 @@ template class CompactArray::Reader final { public: - Reader(ReadBuffer & in_) + explicit Reader(ReadBuffer & in_) : in(in_) { } @@ -177,7 +177,7 @@ class CompactArray::Locus final friend class CompactArray::Reader; public: - ALWAYS_INLINE operator UInt8() const + ALWAYS_INLINE explicit operator UInt8() const { if (content_l == content_r) return read(*content_l); @@ -211,7 +211,7 @@ class CompactArray::Locus final private: Locus() = default; - Locus(BucketIndex bucket_index) + explicit Locus(BucketIndex bucket_index) { init(bucket_index); } diff --git a/dbms/src/Common/ConcurrentBoundedQueue.h b/dbms/src/Common/ConcurrentBoundedQueue.h index d8c63fb51a1..378ea35bde1 100644 --- a/dbms/src/Common/ConcurrentBoundedQueue.h +++ b/dbms/src/Common/ConcurrentBoundedQueue.h @@ -52,7 +52,7 @@ class ConcurrentBoundedQueue Poco::Semaphore empty_count; public: - ConcurrentBoundedQueue(size_t max_fill) + explicit ConcurrentBoundedQueue(size_t max_fill) : fill_count(0, max_fill) , empty_count(max_fill, max_fill) {} diff --git a/dbms/src/Common/Config/ConfigReloader.cpp b/dbms/src/Common/Config/ConfigReloader.cpp index fd6a1ab1fc8..749947800dc 100644 --- a/dbms/src/Common/Config/ConfigReloader.cpp +++ b/dbms/src/Common/Config/ConfigReloader.cpp @@ -132,7 +132,7 @@ void ConfigReloader::FilesChangesTracker::addIfExists(const std::string & path) } } -bool ConfigReloader::FilesChangesTracker::isDifferOrNewerThan(const FilesChangesTracker & rhs) +bool ConfigReloader::FilesChangesTracker::isDifferOrNewerThan(const FilesChangesTracker & rhs) const { return (files.size() != rhs.files.size()) || !std::equal(files.begin(), files.end(), rhs.files.begin(), FileWithTimestamp::isTheSame); } diff --git a/dbms/src/Common/Config/ConfigReloader.h b/dbms/src/Common/Config/ConfigReloader.h index 3aee3640c63..a5995f60387 100644 --- a/dbms/src/Common/Config/ConfigReloader.h +++ b/dbms/src/Common/Config/ConfigReloader.h @@ -45,7 +45,7 @@ class ConfigReloader void reload() { reloadIfNewer(/* force */ true, /* throw_on_error */ true); } protected: - virtual void reloadIfNewer(bool force, bool throw_on_error); + void reloadIfNewer(bool force, bool throw_on_error); Updater & getUpdater() { return updater; } private: @@ -58,7 +58,7 @@ class ConfigReloader std::set files; void addIfExists(const std::string & path); - bool isDifferOrNewerThan(const FilesChangesTracker & rhs); + bool isDifferOrNewerThan(const FilesChangesTracker & rhs) const; }; FilesChangesTracker getNewFileList() const; diff --git a/dbms/src/Common/Config/TOMLConfiguration.cpp b/dbms/src/Common/Config/TOMLConfiguration.cpp index 52b459e7599..58124f4fd32 100644 --- a/dbms/src/Common/Config/TOMLConfiguration.cpp +++ b/dbms/src/Common/Config/TOMLConfiguration.cpp @@ -50,7 +50,7 @@ bool TOMLConfiguration::getRaw(const std::string & key, std::string & value) con } } -bool TOMLConfiguration::find_parent(const std::string & key, TOMLTablePtr & parent, std::string & child_key) +bool TOMLConfiguration::findParent(const std::string & key, TOMLTablePtr & parent, std::string & child_key) { auto pos = key.find_last_of('.'); @@ -85,7 +85,7 @@ void TOMLConfiguration::setRaw(const std::string & key, const std::string & valu { TOMLTablePtr parent; std::string child_key; - if (!find_parent(key, parent, child_key)) + if (!findParent(key, parent, child_key)) throw Poco::NotFoundException("Key not found in TOML configuration", key); parent->erase(child_key); @@ -100,8 +100,8 @@ void TOMLConfiguration::enumerate(const std::string & key, Keys & range) const if (!table) return; - for (auto it = table->begin(); it != table->end(); it++) - range.push_back(it->first); + for (const auto & it : *table) + range.push_back(it.first); } void TOMLConfiguration::removeRaw(const std::string & key) @@ -109,7 +109,7 @@ void TOMLConfiguration::removeRaw(const std::string & key) TOMLTablePtr parent; std::string child_key; - if (find_parent(key, parent, child_key)) + if (findParent(key, parent, child_key)) parent->erase(child_key); } diff --git a/dbms/src/Common/Config/TOMLConfiguration.h b/dbms/src/Common/Config/TOMLConfiguration.h index c4c3ee2989d..5026f32170c 100644 --- a/dbms/src/Common/Config/TOMLConfiguration.h +++ b/dbms/src/Common/Config/TOMLConfiguration.h @@ -16,7 +16,7 @@ using TOMLTablePtr = std::shared_ptr; class TOMLConfiguration : public Poco::Util::AbstractConfiguration { public: - TOMLConfiguration(TOMLTablePtr toml_doc); + explicit TOMLConfiguration(TOMLTablePtr toml_doc); protected: bool getRaw(const std::string & key, std::string & value) const; @@ -36,7 +36,7 @@ class TOMLConfiguration : public Poco::Util::AbstractConfiguration /// Does nothing if the key does not exist. private: TOMLTablePtr root; - bool find_parent(const std::string & key, TOMLTablePtr & parent, std::string & child_key); + bool findParent(const std::string & key, TOMLTablePtr & parent, std::string & child_key); }; } // namespace DB diff --git a/dbms/src/Common/CurrentMetrics.h b/dbms/src/Common/CurrentMetrics.h index 0d5d84d5a0e..e848c79ba5d 100644 --- a/dbms/src/Common/CurrentMetrics.h +++ b/dbms/src/Common/CurrentMetrics.h @@ -72,7 +72,7 @@ class Increment } public: - Increment(Metric metric, Value amount = 1) + explicit Increment(Metric metric, Value amount = 1) : Increment(&values[metric], amount) {}