mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
refs #937 Resolved clazy warnings: unnecessary detaching of containers.
This commit is contained in:
@@ -182,14 +182,14 @@ namespace BlackMisc
|
||||
CValueCache::Element &CValueCache::getElement(const QString &key)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
return getElement(key, m_elements.lowerBound(key));
|
||||
return getElement(key, as_const(m_elements).lowerBound(key));
|
||||
}
|
||||
|
||||
CValueCache::Element &CValueCache::getElement(const QString &key, QMap<QString, ElementPtr>::const_iterator pos)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if (pos != m_elements.end() && pos.key() == key) { return **pos; }
|
||||
Q_ASSERT(pos == m_elements.lowerBound(key));
|
||||
if (pos != m_elements.cend() && pos.key() == key) { return **pos; }
|
||||
Q_ASSERT(pos == as_const(m_elements).lowerBound(key));
|
||||
return **m_elements.insert(pos, key, ElementPtr(new Element(key)));
|
||||
}
|
||||
|
||||
@@ -259,8 +259,9 @@ namespace BlackMisc
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if (values.empty()) { return; }
|
||||
auto out = m_elements.lowerBound(values.cbegin().key());
|
||||
auto end = m_elements.upperBound((values.cend() - 1).key());
|
||||
m_elements.detach(); //! \fixme see http://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem
|
||||
auto out = as_const(m_elements).lowerBound(values.cbegin().key());
|
||||
auto end = as_const(m_elements).upperBound((values.cend() - 1).key());
|
||||
for (auto in = values.cbegin(); in != values.cend(); ++in)
|
||||
{
|
||||
while (out != end && out.key() < in.key()) { ++out; }
|
||||
@@ -295,8 +296,9 @@ namespace BlackMisc
|
||||
}
|
||||
CValueCachePacket ratifiedChanges(values.isSaved());
|
||||
CValueCachePacket ackedChanges(values.isSaved());
|
||||
auto out = m_elements.lowerBound(values.cbegin().key());
|
||||
auto end = m_elements.upperBound((values.cend() - 1).key());
|
||||
m_elements.detach(); //! \fixme see http://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem
|
||||
auto out = as_const(m_elements).lowerBound(values.cbegin().key());
|
||||
auto end = as_const(m_elements).upperBound((values.cend() - 1).key());
|
||||
for (auto in = values.cbegin(); in != values.cend(); ++in)
|
||||
{
|
||||
while (out != end && out.key() < in.key()) { ++out; }
|
||||
|
||||
Reference in New Issue
Block a user