Skip to content

Commit 16287cc

Browse files
committed
Cleanup some clang-tidy issues
1 parent e4b6668 commit 16287cc

8 files changed

Lines changed: 27 additions & 21 deletions

File tree

examples/btree.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
int main()
66
{
7-
// initialise map with some values using an initializer_list
7+
phmap::btree_multimap<int, int> foo;
8+
for (auto it = foo.begin(); it != foo.end(); it++) {
9+
}
10+
11+
// initialise map with some values using an initializer_list
812
phmap::btree_map<std::string, int> map =
913
{ { "John", 35 },
1014
{ "Jane", 32 },

examples/matt.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cstdlib>
55
#include <cstdio>
66
#include <cmath>
7+
#include <utility>
78
#include <vector>
89
#include <random>
910
#include <parallel_hashmap/phmap.h>
@@ -14,7 +15,7 @@
1415
class Timer
1516
{
1617
public:
17-
Timer(std::string name) : _name(name), _start(std::chrono::high_resolution_clock::now()) {}
18+
Timer(std::string name) : _name(std::move(name)), _start(std::chrono::high_resolution_clock::now()) {}
1819

1920
~Timer()
2021
{
@@ -63,7 +64,7 @@ using Perturb = std::function<void (std::vector<uint64_t> &)>;
6364
// --------------------------------------------------------------------------
6465
// --------------------------------------------------------------------------
6566
template<class Set, size_t N>
66-
void test(const char *name, Perturb perturb1, Perturb /* perturb2 */)
67+
void test(const char *name, const Perturb &perturb1, const Perturb& /* perturb2 */)
6768
{
6869
//phmap::btree_set<uint64_t> s;
6970
Set s;

examples/mt_word_counter.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ int main() {
4848

4949
// run 4 threads, each thread processing lines from one of the vectors
5050
// -------------------------------------------------------------------
51+
threads.reserve(num_threads);
5152
for (int i = 0; i < num_threads; ++i) {
5253
threads.emplace_back(
5354
[&word_counts](std::vector<std::string>&& lines) {

examples/pmr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct MyStruct
1616
{
1717
template<typename Key, typename Value>
1818
using ParallelFlatHashMap = phmap::parallel_flat_hash_map<Key, Value, std::hash<Key>, std::equal_to<Key>,
19-
std::pmr::polymorphic_allocator<std::pair<const Key, Value>>>;
19+
std::pmr::polymorphic_allocator<std::pair<const Key, Value>>>;
2020

2121
ParallelFlatHashMap<uint32_t, uint32_t> hashMap;
2222

examples/serialize.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class RSU
5555

5656
// --------------------------------------------------------------------------
5757
// --------------------------------------------------------------------------
58-
void showtime(const char *name, std::function<void ()> doit)
58+
void showtime(const char *name, const std::function<void ()>& doit)
5959
{
6060
auto t1 = std::chrono::high_resolution_clock::now();
6161
doit();

parallel_hashmap/btree.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,13 @@ namespace priv {
737737
StringBtreeDefaultLess(std::less<std::string_view>) {} // NOLINT
738738
StringBtreeDefaultLess(phmap::Less<std::string_view>) {} // NOLINT
739739

740-
phmap::weak_ordering operator()(std::string_view lhs,
741-
std::string_view rhs) const {
740+
phmap::weak_ordering operator()(const std::string_view &lhs,
741+
const std::string_view &rhs) const {
742742
return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
743743
}
744744
#else
745-
phmap::weak_ordering operator()(std::string lhs,
746-
std::string rhs) const {
745+
phmap::weak_ordering operator()(const std::string &lhs,
746+
const std::string &rhs) const {
747747
return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
748748
}
749749
#endif
@@ -763,8 +763,8 @@ namespace priv {
763763
return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
764764
}
765765
#else
766-
phmap::weak_ordering operator()(std::string lhs,
767-
std::string rhs) const {
766+
phmap::weak_ordering operator()(const std::string &lhs,
767+
const std::string &rhs) const {
768768
return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
769769
}
770770
#endif

parallel_hashmap/phmap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,9 @@ class raw_hash_set
11901190
size_(phmap::exchange(that.size_, 0)),
11911191
capacity_(phmap::exchange(that.capacity_, 0)),
11921192
infoz_(phmap::exchange(that.infoz_, HashtablezInfoHandle())),
1193-
// Hash, equality and allocator are copied instead of moved because
1194-
// `that` must be left valid. If Hash is std::function<Key>, moving it
1195-
// would create a nullptr functor that cannot be called.
1193+
// Hash, equality and allocator are copied instead of moved because
1194+
// `that` must be left valid. If Hash is std::function<Key>, moving it
1195+
// would create a nullptr functor that cannot be called.
11961196
settings_(that.settings_) {
11971197
// growth_left was copied above, reset the one from `that`.
11981198
that.growth_left() = 0;

parallel_hashmap/phmap_base.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ class optional : private optional_internal::optional_data<T>,
20472047
optional(const optional& src) = default;
20482048

20492049
// Move constructor, standard semantics
2050-
optional(optional&& src) = default;
2050+
optional(optional&& src) noexcept = default;
20512051

20522052
// Constructs a non-empty `optional` direct-initialized value of type `T` from
20532053
// the arguments `std::forward<Args>(args)...` within the `optional`.
@@ -2187,7 +2187,7 @@ class optional : private optional_internal::optional_data<T>,
21872187
optional& operator=(const optional& src) = default;
21882188

21892189
// Move assignment operator, standard semantics
2190-
optional& operator=(optional&& src) = default;
2190+
optional& operator=(optional&& src) noexcept = default;
21912191

21922192
// Value assignment operators
21932193
template <
@@ -4765,7 +4765,7 @@ class LockableBaseImpl
47654765
DoNothing(mutex_type&, phmap::try_to_lock_t) {}
47664766
template<class T> explicit DoNothing(T&&) {}
47674767
DoNothing& operator=(const DoNothing&) { return *this; }
4768-
DoNothing& operator=(DoNothing&&) { return *this; }
4768+
DoNothing& operator=(DoNothing&&) noexcept { return *this; }
47694769
void swap(DoNothing &) {}
47704770
bool owns_lock() const noexcept { return true; }
47714771
};
@@ -4796,13 +4796,13 @@ class LockableBaseImpl
47964796
m_->try_lock();
47974797
}
47984798

4799-
WriteLock(WriteLock &&o) :
4799+
WriteLock(WriteLock &&o) noexcept :
48004800
m_(std::move(o.m_)), locked_(std::move(o.locked_)) {
48014801
o.locked_ = false;
48024802
o.m_ = nullptr;
48034803
}
48044804

4805-
WriteLock& operator=(WriteLock&& other) {
4805+
WriteLock& operator=(WriteLock&& other) noexcept {
48064806
WriteLock temp(std::move(other));
48074807
swap(temp);
48084808
return *this;
@@ -4874,13 +4874,13 @@ class LockableBaseImpl
48744874
m_->try_lock_shared();
48754875
}
48764876

4877-
ReadLock(ReadLock &&o) :
4877+
ReadLock(ReadLock &&o) noexcept :
48784878
m_(std::move(o.m_)), locked_(std::move(o.locked_)) {
48794879
o.locked_ = false;
48804880
o.m_ = nullptr;
48814881
}
48824882

4883-
ReadLock& operator=(ReadLock&& other) {
4883+
ReadLock& operator=(ReadLock&& other) noexcept {
48844884
ReadLock temp(std::move(other));
48854885
swap(temp);
48864886
return *this;

0 commit comments

Comments
 (0)