From 7cba2acd2cc4b68b5a4de2251ab555adb09bf7e8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 2 May 2019 18:51:57 +0200 Subject: qmake: replace QLinkedList with std::list This is in preparation of deprecating QLinkedList. There is but one substantial change: Instead of copying the linked list, we move it now, and instead of copying items between these two lists, we use std::list::splice(), which just relinks nodes. It is a bit surprising that the comment on the ProValueMapStack suggests references into the container must remain stable, and then some code changes addresses by making copies of the elements. This was probably a bug waiting to manifest itself. Since nothing else in qmake is using QLinkedList now, remove qlinkedlist.o from the qmake build. Change-Id: I08a5b0661466bf50ad8f9f8abf58bc801aef4ddc Reviewed-by: Joerg Bornemann --- qmake/Makefile.unix | 6 +----- qmake/Makefile.win32 | 1 - qmake/library/qmakeevaluator.cpp | 10 ++++++---- qmake/library/qmakeevaluator.h | 7 ++++--- qmake/qmake.pro | 2 -- 5 files changed, 11 insertions(+), 15 deletions(-) (limited to 'qmake') diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 0f69b6b487..166ec33c1b 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -28,7 +28,7 @@ QOBJS = \ qmetatype.o qsystemerror.o qvariant.o \ quuid.o \ qarraydata.o qbitarray.o qbytearray.o qbytearraymatcher.o \ - qcryptographichash.o qdatetime.o qhash.o qlinkedlist.o qlist.o \ + qcryptographichash.o qdatetime.o qhash.o qlist.o \ qlocale.o qlocale_tools.o qmap.o qregexp.o qringbuffer.o \ qstringbuilder.o qstring_compat.o qstring.o qstringlist.o qversionnumber.o \ qvsnprintf.o qxmlstream.o qxmlutils.o \ @@ -112,7 +112,6 @@ DEPEND_SRC = \ $(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp \ $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp \ $(SOURCE_PATH)/src/corelib/tools/qhash.cpp \ - $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlocale.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlocale_tools.cpp \ @@ -442,9 +441,6 @@ qmap.o: $(SOURCE_PATH)/src/corelib/tools/qmap.cpp qhash.o: $(SOURCE_PATH)/src/corelib/tools/qhash.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< -qlinkedlist.o: $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $< - qcryptographichash.o: $(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 6ab40c6765..1777741df4 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -88,7 +88,6 @@ QTOBJS= \ qringbuffer.obj \ qdebug.obj \ qlist.obj \ - qlinkedlist.obj \ qlocale.obj \ qlocale_tools.obj \ qlocale_win.obj \ diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index d7ff4ede39..c9dc7bd80b 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -601,14 +601,16 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock( case TokBypassNesting: blockLen = getBlockLen(tokPtr); if ((m_cumulative || okey != or_op) && blockLen) { - ProValueMapStack savedValuemapStack = m_valuemapStack; + ProValueMapStack savedValuemapStack = std::move(m_valuemapStack); m_valuemapStack.clear(); - m_valuemapStack.append(savedValuemapStack.takeFirst()); + m_valuemapStack.splice(m_valuemapStack.end(), + savedValuemapStack, savedValuemapStack.begin()); traceMsg("visiting nesting-bypassing block"); ret = visitProBlock(tokPtr); traceMsg("visited nesting-bypassing block"); - savedValuemapStack.prepend(m_valuemapStack.first()); - m_valuemapStack = savedValuemapStack; + savedValuemapStack.splice(savedValuemapStack.begin(), + m_valuemapStack, m_valuemapStack.begin()); + m_valuemapStack = std::move(savedValuemapStack); } else { traceMsg("skipped nesting-bypassing block"); ret = ReturnTrue; diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 2aebb825ea..9f702b9182 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -38,7 +38,6 @@ #include "ioutils.h" #include -#include #include #include #include @@ -54,6 +53,8 @@ # include #endif +#include + QT_BEGIN_NAMESPACE class QMakeGlobals; @@ -94,9 +95,9 @@ public: #endif }; -// We use a QLinkedList based stack instead of a QVector based one (QStack), so that +// We use a list-based stack instead of a vector-based one, so that // the addresses of value maps stay constant. The qmake generators rely on that. -class QMAKE_EXPORT ProValueMapStack : public QLinkedList +class QMAKE_EXPORT ProValueMapStack : public std::list { public: inline void push(const ProValueMap &t) { push_back(t); } diff --git a/qmake/qmake.pro b/qmake/qmake.pro index 6a6116c8db..276c1237a9 100644 --- a/qmake/qmake.pro +++ b/qmake/qmake.pro @@ -136,7 +136,6 @@ SOURCES += \ qjsonparser.cpp \ qjsonvalue.cpp \ qlibraryinfo.cpp \ - qlinkedlist.cpp \ qlist.cpp \ qlocale.cpp \ qlocale_tools.cpp \ @@ -189,7 +188,6 @@ HEADERS += \ qjsonparser_p.h \ qjsonvalue.h \ qjsonwriter_p.h \ - qlinkedlist.h \ qlist.h \ qlocale.h \ qlocale_tools_p.h \ -- cgit v1.2.3