mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #501, compareByPropertyIndex (performance for sort)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1e57ce7ecb
commit
0c94922bd6
@@ -36,12 +36,11 @@ namespace BlackMisc
|
||||
|
||||
CPropertyIndex CPropertyIndex::copyFrontRemoved() const
|
||||
{
|
||||
Q_ASSERT(!this->isEmpty());
|
||||
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "Empty index");
|
||||
if (this->isEmpty()) { return CPropertyIndex(); }
|
||||
QList<int> l = this->indexList();
|
||||
l.removeAt(0);
|
||||
CPropertyIndex pi(l);
|
||||
return pi;
|
||||
int p = this->m_indexString.indexOf(';');
|
||||
if (p < 0) { return CPropertyIndex(); }
|
||||
return CPropertyIndex(this->m_indexString.mid(p + 1));
|
||||
}
|
||||
|
||||
bool CPropertyIndex::isNested() const
|
||||
@@ -102,7 +101,7 @@ namespace BlackMisc
|
||||
QList<int> list;
|
||||
if (this->m_indexString.isEmpty()) { return list; }
|
||||
QStringList indexes = this->m_indexString.split(';');
|
||||
foreach(QString index, indexes)
|
||||
for (const QString &index : indexes)
|
||||
{
|
||||
if (index.isEmpty()) { continue; }
|
||||
bool ok;
|
||||
@@ -126,4 +125,22 @@ namespace BlackMisc
|
||||
return this->indexList().contains(index);
|
||||
}
|
||||
|
||||
int CPropertyIndex::frontToInt() const
|
||||
{
|
||||
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "No index");
|
||||
int f = -1;
|
||||
bool ok;
|
||||
int p = this->m_indexString.indexOf(';');
|
||||
if (p < 0)
|
||||
{
|
||||
f = this->m_indexString.toInt(&ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = this->m_indexString.left(p).toInt(&ok);
|
||||
}
|
||||
Q_ASSERT_X(ok && f >= 0, Q_FUNC_INFO, "Invalid index");
|
||||
return f;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user