summaryrefslogtreecommitdiffstats
path: root/src/tools/qlalr/lalr.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-02 19:56:29 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-02 22:27:11 +0200
commitdce7dbecb0135501eb8641c8f5ec8e98bddc808c (patch)
treeef3da870c951e5c838dde1ceb680d7d53b56c3ed /src/tools/qlalr/lalr.cpp
parent13997cccc9dd9a1242b7707b5e934deae84d253a (diff)
qlalr: replace QLinkedList with std::list
This is in preparation of deprecating QLinkedList. Most is straight-forward, except where operator+ was used on linked-list iterators. In one case, replaced this with std::next, in the other, with prefix increments, since the advancement was always equal to the loop control variable. Since advancing a linked-list iterator is a linear operation, this removes a source of quadratic complexity. Another obstacle was the overloaded op< set, which was in the Qt namespace while the iterator is from std and the payload, as before, was global. This breaks ADL, so move these operators to namespace std. This violates the standard, but the functions are tagged with our distinct types, so it shouldn't cause any trouble. Change-Id: Ifec0a927bfdabb002838cdf86fb8d23b32a38ff7 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/tools/qlalr/lalr.cpp')
-rw-r--r--src/tools/qlalr/lalr.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp
index 8af3b3c0db..b9a9cf264f 100644
--- a/src/tools/qlalr/lalr.cpp
+++ b/src/tools/qlalr/lalr.cpp
@@ -51,7 +51,9 @@ QTextStream &qout()
static QTextStream result(stdout, QIODevice::WriteOnly);
return result;
}
+QT_END_NAMESPACE
+namespace std {
bool operator < (Name a, Name b)
{
return *a < *b;
@@ -66,7 +68,7 @@ bool operator < (StatePointer a, StatePointer b)
{
return &*a < &*b;
}
-QT_END_NAMESPACE
+}
bool Read::operator < (const Read &other) const
{
@@ -329,7 +331,7 @@ QPair<StatePointer, bool> Automaton::internState (const State &state)
struct _Bucket
{
- QLinkedList<ItemPointer> items;
+ std::list<ItemPointer> items;
void insert (ItemPointer item)
{ items.push_back (item); }
@@ -338,8 +340,8 @@ struct _Bucket
{
State st (aut->_M_grammar);
- for (QLinkedList<ItemPointer>::iterator item = items.begin (); item != items.end (); ++item)
- st.insert ((*item)->next ());
+ for (auto &item : items)
+ st.insert(item->next());
return st;
}