diff options
Diffstat (limited to 'src/util/container.h')
-rw-r--r-- | src/util/container.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/util/container.h b/src/util/container.h index 2ad2bbfc7..1c4a219f0 100644 --- a/src/util/container.h +++ b/src/util/container.h @@ -90,8 +90,7 @@ public: bool get(const Key &name, Value *result) const { MutexAutoLock lock(m_mutex); - typename std::map<Key, Value>::const_iterator n = - m_values.find(name); + auto n = m_values.find(name); if (n == m_values.end()) return false; if (result) @@ -103,11 +102,9 @@ public: { MutexAutoLock lock(m_mutex); std::vector<Value> result; - for (typename std::map<Key, Value>::const_iterator - it = m_values.begin(); - it != m_values.end(); ++it){ + result.reserve(m_values.size()); + for (auto it = m_values.begin(); it != m_values.end(); ++it) result.push_back(it->second); - } return result; } @@ -136,7 +133,7 @@ public: return m_queue.empty(); } - void push_back(T t) + void push_back(const T &t) { MutexAutoLock lock(m_mutex); m_queue.push_back(t); @@ -151,7 +148,7 @@ public: if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); - T t = m_queue.front(); + T t = std::move(m_queue.front()); m_queue.pop_front(); return t; } @@ -164,7 +161,7 @@ public: if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); - T t = m_queue.front(); + T t = std::move(m_queue.front()); m_queue.pop_front(); return t; } @@ -178,7 +175,7 @@ public: MutexAutoLock lock(m_mutex); - T t = m_queue.front(); + T t = std::move(m_queue.front()); m_queue.pop_front(); return t; } @@ -188,7 +185,7 @@ public: if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); - T t = m_queue.back(); + T t = std::move(m_queue.back()); m_queue.pop_back(); return t; } @@ -204,7 +201,7 @@ public: if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); - T t = m_queue.back(); + T t = std::move(m_queue.back()); m_queue.pop_back(); return t; } @@ -218,7 +215,7 @@ public: MutexAutoLock lock(m_mutex); - T t = m_queue.back(); + T t = std::move(m_queue.back()); m_queue.pop_back(); return t; } |