qlalr: remove uses of inefficient QLists
For QList<QLinkedList<T>::iterator>, mark the iterator Q_PRIMITIVE_TYPE. This should be done in Qt itself, but would be binary incompatible. For two other types that are used as values in QMultiMap, replaced foreach (x, map.values(y)) with auto range = map.equal_range(y); for (auto it = range.first; it != ramge.second; ++it) x = *it; which doesn't require a temporary QList. Change-Id: I9ddd15dd9b1d5bb3000833d14ed911451a272328 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
parent
18597b2ae2
commit
cf9d112d7a
@ -362,8 +362,10 @@ void Automaton::closure (StatePointer state)
|
|||||||
|
|
||||||
if (_M_grammar->isNonTerminal (*item->dot))
|
if (_M_grammar->isNonTerminal (*item->dot))
|
||||||
{
|
{
|
||||||
foreach (const RulePointer &rule, _M_grammar->rule_map.values (*item->dot))
|
const auto range = qAsConst(_M_grammar->rule_map).equal_range(*item->dot);
|
||||||
|
for (auto it = range.first; it != range.second; ++it)
|
||||||
{
|
{
|
||||||
|
const RulePointer &rule = *it;
|
||||||
Item ii;
|
Item ii;
|
||||||
ii.rule = rule;
|
ii.rule = rule;
|
||||||
ii.dot = rule->rhs.begin ();
|
ii.dot = rule->rhs.begin ();
|
||||||
@ -701,8 +703,10 @@ void Automaton::buildLookaheads ()
|
|||||||
{
|
{
|
||||||
for (ItemPointer item = p->closure.begin (); item != p->closure.end (); ++item)
|
for (ItemPointer item = p->closure.begin (); item != p->closure.end (); ++item)
|
||||||
{
|
{
|
||||||
foreach (const Lookback &lookback, lookbacks.values (item))
|
const auto range = qAsConst(lookbacks).equal_range(item);
|
||||||
|
for (auto it = range.first; it != range.second; ++it)
|
||||||
{
|
{
|
||||||
|
const Lookback &lookback = *it;
|
||||||
StatePointer q = lookback.state;
|
StatePointer q = lookback.state;
|
||||||
|
|
||||||
#ifndef QLALR_NO_DEBUG_LOOKAHEADS
|
#ifndef QLALR_NO_DEBUG_LOOKAHEADS
|
||||||
|
@ -134,21 +134,33 @@ public:
|
|||||||
|
|
||||||
// names
|
// names
|
||||||
typedef QLinkedList<QString>::iterator Name;
|
typedef QLinkedList<QString>::iterator Name;
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
Q_DECLARE_TYPEINFO(QLinkedList<QString>::iterator, Q_PRIMITIVE_TYPE);
|
||||||
|
QT_END_NAMESPACE
|
||||||
typedef QLinkedList<Name> NameList;
|
typedef QLinkedList<Name> NameList;
|
||||||
typedef OrderedSet<Name> NameSet;
|
typedef OrderedSet<Name> NameSet;
|
||||||
|
|
||||||
// items
|
// items
|
||||||
typedef QLinkedList<Item> ItemList;
|
typedef QLinkedList<Item> ItemList;
|
||||||
typedef ItemList::iterator ItemPointer;
|
typedef ItemList::iterator ItemPointer;
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
Q_DECLARE_TYPEINFO(ItemList::iterator, Q_PRIMITIVE_TYPE);
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
typedef QLinkedList<Rule> debug_infot;
|
typedef QLinkedList<Rule> debug_infot;
|
||||||
typedef debug_infot::iterator RulePointer;
|
typedef debug_infot::iterator RulePointer;
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
Q_DECLARE_TYPEINFO(debug_infot::iterator, Q_PRIMITIVE_TYPE);
|
||||||
|
QT_END_NAMESPACE
|
||||||
typedef QMultiMap<Name, RulePointer> RuleMap;
|
typedef QMultiMap<Name, RulePointer> RuleMap;
|
||||||
|
|
||||||
// states
|
// states
|
||||||
typedef QLinkedList<State> StateList;
|
typedef QLinkedList<State> StateList;
|
||||||
typedef StateList::iterator StatePointer;
|
typedef StateList::iterator StatePointer;
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
Q_DECLARE_TYPEINFO(StateList::iterator, Q_PRIMITIVE_TYPE);
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
// arrows
|
// arrows
|
||||||
typedef QMap<Name, StatePointer> Bundle;
|
typedef QMap<Name, StatePointer> Bundle;
|
||||||
|
Loading…
Reference in New Issue
Block a user