diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-01-02 16:49:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-09 17:16:03 +0100 |
commit | 7701b58ad06f9e99d291e0e3468096dc3ab4dd00 (patch) | |
tree | 4179a1d22c59e783c50201732c65e1af1fe52203 /src/qml/debugger/qqmlprofilerservice_p.h | |
parent | e20324ea5cdc63145a25be3027c21d1bdfed03b6 (diff) |
Remove redundant copies of enabled flag in QML profiler
Task-number: QTBUG-35315
Change-Id: Idd35a330531722cb3d4e0d3e95cb3be6e5697688
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/qml/debugger/qqmlprofilerservice_p.h')
-rw-r--r-- | src/qml/debugger/qqmlprofilerservice_p.h | 72 |
1 files changed, 22 insertions, 50 deletions
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h index 5959a526bb..86807eacec 100644 --- a/src/qml/debugger/qqmlprofilerservice_p.h +++ b/src/qml/debugger/qqmlprofilerservice_p.h @@ -237,32 +237,25 @@ private: struct QQmlBindingProfiler { QQmlBindingProfiler(const QString &url, int line, int column, QQmlProfilerService::BindingType bindingType) { - QQmlProfilerService *instance = QQmlProfilerService::instance; - enabled = instance ? instance->profilingEnabled() : false; - if (enabled) { - instance->startRange(QQmlProfilerService::Binding, bindingType); - instance->rangeLocation(QQmlProfilerService::Binding, url, line, column); + if (QQmlProfilerService::enabled) { + QQmlProfilerService::instance->startRange(QQmlProfilerService::Binding, bindingType); + QQmlProfilerService::instance->rangeLocation(QQmlProfilerService::Binding, url, line, column); } } ~QQmlBindingProfiler() { - if (enabled) + if (QQmlProfilerService::enabled) QQmlProfilerService::instance->endRange(QQmlProfilerService::Binding); } - - bool enabled; }; struct QQmlHandlingSignalProfiler { QQmlHandlingSignalProfiler(QQmlBoundSignalExpression *expression) { - enabled = QQmlProfilerService::instance - ? QQmlProfilerService::instance->profilingEnabled() : false; - if (enabled) { - QQmlProfilerService *service = QQmlProfilerService::instance; - service->startRange(QQmlProfilerService::HandlingSignal); - service->rangeLocation(QQmlProfilerService::HandlingSignal, + if (QQmlProfilerService::enabled) { + QQmlProfilerService::instance->startRange(QQmlProfilerService::HandlingSignal); + QQmlProfilerService::instance->rangeLocation(QQmlProfilerService::HandlingSignal, expression->sourceFile(), expression->lineNumber(), expression->columnNumber()); } @@ -270,38 +263,30 @@ struct QQmlHandlingSignalProfiler { ~QQmlHandlingSignalProfiler() { - if (enabled) + if (QQmlProfilerService::enabled) QQmlProfilerService::instance->endRange(QQmlProfilerService::HandlingSignal); } - - bool enabled; }; struct QQmlCompilingProfiler { QQmlCompilingProfiler(const QString &name) { - QQmlProfilerService *instance = QQmlProfilerService::instance; - enabled = instance ? - instance->profilingEnabled() : false; - if (enabled) { - instance->startRange(QQmlProfilerService::Compiling); - instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1); - instance->rangeData(QQmlProfilerService::Compiling, name); + if (QQmlProfilerService::enabled) { + QQmlProfilerService::instance->startRange(QQmlProfilerService::Compiling); + QQmlProfilerService::instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1); + QQmlProfilerService::instance->rangeData(QQmlProfilerService::Compiling, name); } } ~QQmlCompilingProfiler() { - if (enabled) + if (QQmlProfilerService::enabled) QQmlProfilerService::instance->endRange(QQmlProfilerService::Compiling); } - - bool enabled; }; struct QQmlVmeProfiler { public: - const bool enabled; struct Data { Data() : line(0), column(0) {} @@ -313,20 +298,18 @@ public: }; QQmlVmeProfiler() : - enabled(QQmlProfilerService::instance ? QQmlProfilerService::instance->profilingEnabled() : false), running(false) {} ~QQmlVmeProfiler() { - if (enabled) + if (QQmlProfilerService::enabled) clear(); } void clear(); - void start(const QUrl &url, int line, int column, const QString &typeName); - void start(); + bool start(); void stop(); void updateLocation(const QUrl &url, int line, int column); @@ -336,10 +319,9 @@ public: void push(); void background(); - void foreground(); + bool foreground(); private: - void switchRange(); Data currentRange; QStack<Data> ranges; @@ -348,46 +330,36 @@ private: }; struct QQmlPixmapProfiler { - QQmlPixmapProfiler() { - QQmlProfilerService *instance = QQmlProfilerService::instance; - enabled = instance ? - instance->profilingEnabled() : false; - } - - ~QQmlPixmapProfiler() {} - void startLoading(const QUrl &pixmapUrl) { - if (enabled) { + if (QQmlProfilerService::enabled) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingStarted, pixmapUrl); } } void finishLoading(const QUrl &pixmapUrl) { - if (enabled) { + if (QQmlProfilerService::enabled) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingFinished, pixmapUrl); } } void errorLoading(const QUrl &pixmapUrl) { - if (enabled) { + if (QQmlProfilerService::enabled) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingError, pixmapUrl); } } void cacheCountChanged(const QUrl &pixmapUrl, int cacheCount) { - if (enabled) { + if (QQmlProfilerService::enabled) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapCacheCountChanged, pixmapUrl, cacheCount); } } void referenceCountChanged(const QUrl &pixmapUrl, int referenceCount) { - if (enabled) { + if (QQmlProfilerService::enabled) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapReferenceCountChanged, pixmapUrl, referenceCount); } } void setSize(const QUrl &pixmapUrl, const QSize &size) { - if (enabled && size.width() > 0) { + if (QQmlProfilerService::enabled && size.width() > 0) { QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapSizeKnown, pixmapUrl, size.width(), size.height()); } } - - bool enabled; }; QT_END_NAMESPACE |