Skip to content

Commit f7c9450

Browse files
pmelkozerdrewdzzz
authored andcommitted
utils: std::forward related fixes
std::forward were replace std::move for fixed type context where it does not make sense. Some redundant comment were removed as they declare obvious actions under them.
1 parent 17f3171 commit f7c9450

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/Buffer/Buffer.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,7 @@ class Buffer {
274274
Buffer(allocator &&all = allocator());
275275
Buffer(const Buffer& buf) = delete;
276276
Buffer& operator = (const Buffer& buf) = delete;
277-
Buffer(Buffer &&other) noexcept
278-
{
279-
/* Call move assignment operator. */
280-
*this = std::forward<Buffer>(other);
281-
}
277+
Buffer(Buffer &&other) noexcept { *this = std::move(other); }
282278
Buffer &operator=(Buffer &&other) noexcept
283279
{
284280
if (this == &other)

src/Utils/Mempool.hpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ class MempoolStats {
4646
void statDelBlock() { --m_BlockCount; }
4747
public:
4848
MempoolStats() = default;
49-
MempoolStats(MempoolStats &&other) noexcept
50-
{
51-
/* Call move assignment operator. */
52-
*this = std::forward<MempoolStats>(other);
53-
}
49+
MempoolStats(MempoolStats &&other) noexcept { *this = std::move<MempoolStats>(other); }
5450
MempoolStats &operator=(MempoolStats &&other) noexcept
5551
{
5652
std::swap(m_SlabCount, other.m_SlabCount);
@@ -134,17 +130,13 @@ class MempoolInstance : public MempoolStats<ENABLE_STATS> {
134130
MempoolInstance() = default;
135131
MempoolInstance(const MempoolInstance &other) = delete;
136132
MempoolInstance &operator=(const MempoolInstance &other) = delete;
137-
MempoolInstance(MempoolInstance &&other) noexcept
138-
{
139-
/* Call move assignment operator. */
140-
*this = std::forward<MempoolInstance>(other);
141-
}
133+
MempoolInstance(MempoolInstance &&other) noexcept { *this = std::move(other); }
142134
MempoolInstance &operator=(MempoolInstance &&other) noexcept
143135
{
144136
if (this == &other)
145137
return *this;
146138
/* Move base class. */
147-
MempoolStats<ENABLE_STATS>::operator=(std::forward<MempoolInstance>(other));
139+
MempoolStats<ENABLE_STATS>::operator=(std::move(other));
148140
std::swap(m_SlabList, other.m_SlabList);
149141
std::swap(m_FreeList, other.m_FreeList);
150142
std::swap(m_SlabDataBeg, other.m_SlabDataBeg);

0 commit comments

Comments
 (0)