From 297be273a34b33cf19af0fb2d2bec6df8d3809b6 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 29 Apr 2014 12:39:31 +0200 Subject: [PATCH] De-inline QDebug destructor This injected quite some code on every use of qDebug and friends, while not giving any measurable performance benefits. Change-Id: I7b51f99130f18f1252da01e313f7b97c43a5480d Reviewed-by: Orgad Shaneh Reviewed-by: Thiago Macieira --- qmake/Makefile.unix | 7 ++++++- qmake/Makefile.win32 | 1 + src/corelib/io/qdebug.cpp | 14 ++++++++++++++ src/corelib/io/qdebug.h | 13 +------------ tools/configure/Makefile.mingw | 1 + tools/configure/Makefile.win32 | 2 ++ tools/configure/configure.pro | 1 + 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index ef1c542f57..52873203a0 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -12,7 +12,8 @@ OBJS=project.o option.o property.o main.o ioutils.o proitems.o \ gbuild.o cesdkhandler.o #qt code -QOBJS=qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ +QOBJS=qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtextstream.o qiodevice.o \ + qdebug.o qmalloc.o qglobal.o \ qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfiledevice.o qfile.o \ qfilesystementry.o qfilesystemengine.o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qvector.o \ qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o \ @@ -43,6 +44,7 @@ DEPEND_SRC = \ $(SOURCE_PATH)/src/corelib/tools/qstring_compat.cpp \ $(SOURCE_PATH)/src/corelib/io/qfiledevice.cpp \ $(SOURCE_PATH)/src/corelib/io/qtextstream.cpp $(SOURCE_PATH)/src/corelib/io/qiodevice.cpp \ + $(SOURCE_PATH)/src/corelib/io/qdebug.cpp \ $(SOURCE_PATH)/src/corelib/global/qmalloc.cpp \ $(SOURCE_PATH)/src/corelib/global/qglobal.cpp $(SOURCE_PATH)/src/corelib/tools/qregexp.cpp \ $(SOURCE_PATH)/src/corelib/tools/qarraydata.cpp $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp\ @@ -240,6 +242,9 @@ qsettings_win.o: $(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp qiodevice.o: $(SOURCE_PATH)/src/corelib/io/qiodevice.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qiodevice.cpp +qdebug.o: $(SOURCE_PATH)/src/corelib/io/qdebug.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qdebug.cpp + qmalloc.o: $(SOURCE_PATH)/src/corelib/global/qmalloc.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qmalloc.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index b1936f3cec..62dc7bcdf8 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -94,6 +94,7 @@ QTOBJS= \ qglobal.obj \ qhash.obj \ qiodevice.obj \ + qdebug.obj \ qlist.obj \ qlinkedlist.obj \ qlocale.obj \ diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 79038e9138..44d0a788ff 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -128,6 +128,20 @@ QT_BEGIN_NAMESPACE Flushes any pending data to be written and destroys the debug stream. */ +// Has been defined in the header / inlined before Qt 5.4 +QDebug::~QDebug() +{ + if (!--stream->ref) { + if (stream->space && stream->buffer.endsWith(QLatin1Char(' '))) + stream->buffer.chop(1); + if (stream->message_output) { + qt_message_output(stream->type, + stream->context, + stream->buffer); + } + delete stream; + } +} /*! \fn QDebug::swap(QDebug &other) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index a1294d0b40..94b19f9cab 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -78,18 +78,7 @@ public: inline QDebug(QtMsgType t) : stream(new Stream(t)) {} inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; } inline QDebug &operator=(const QDebug &other); - inline ~QDebug() { - if (!--stream->ref) { - if (stream->space && stream->buffer.endsWith(QLatin1Char(' '))) - stream->buffer.chop(1); - if (stream->message_output) { - qt_message_output(stream->type, - stream->context, - stream->buffer); - } - delete stream; - } - } + ~QDebug(); inline void swap(QDebug &other) { qSwap(stream, other.stream); } inline QDebug &space() { stream->space = true; stream->ts << ' '; return *this; } diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw index db8db54888..736c14731e 100644 --- a/tools/configure/Makefile.mingw +++ b/tools/configure/Makefile.mingw @@ -49,6 +49,7 @@ OBJECTS = \ qfsfileengine_win.o \ qfsfileengine_iterator.o \ qiodevice.o \ + qdebug.o \ qtextstream.o \ qlogging.o \ qtemporaryfile.o \ diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32 index 98a2181e39..f783ef8ac3 100644 --- a/tools/configure/Makefile.win32 +++ b/tools/configure/Makefile.win32 @@ -47,6 +47,7 @@ OBJECTS = \ qfsfileengine_win.obj \ qfsfileengine_iterator.obj \ qiodevice.obj \ + qdebug.obj \ qtextstream.obj \ qlogging.obj \ qtemporaryfile.obj \ @@ -121,6 +122,7 @@ qfsfileengine.obj: $(CORESRC)\io\qfsfileengine.cpp $(PCH) qfsfileengine_win.obj: $(CORESRC)\io\qfsfileengine_win.cpp $(PCH) qfsfileengine_iterator.obj: $(CORESRC)\io\qfsfileengine_iterator.cpp $(PCH) qiodevice.obj: $(CORESRC)\io\qiodevice.cpp $(PCH) +qdebug.obj: $(CORESRC)\io\qdebug.cpp $(PCH) qtextstream.obj: $(CORESRC)\io\qtextstream.cpp $(PCH) qtemporaryfile.obj: $(CORESRC)\io\qtemporaryfile.cpp $(PCH) qstandardpaths.obj: $(CORESRC)\io\qstandardpaths.cpp $(PCH) diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index b73a93431d..d3237d472b 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -109,6 +109,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qdebug.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qstandardpaths.cpp \