diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2014-12-19 20:45:55 +0100 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2014-12-20 11:07:02 +0100 |
commit | 42aba3076dc9b6c4f8f35dd79cbf2992f7373d4f (patch) | |
tree | 38ff3c92b80706a09fe7cf9cdd97ebf1f1ba6126 /src/qml/compiler/qv4codegen.cpp | |
parent | 7b8b16e7bc5692ecea1e0773f56366d38ff176c2 (diff) |
QQmlJS::Codegen: Short circuit in qmlErrors to avoid QUrl allocation costs.
This takes the time taken in qmlErrors for my (admittedly terribly morbid)
testcase from ~104ms to ~1ms.
Change-Id: I288086caa6e6b58f67e9feb6f1761c3310f01ead
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index bb27d897a6..ba4c450aae 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2841,6 +2841,11 @@ QList<QQmlJS::DiagnosticMessage> Codegen::errors() const QList<QQmlError> Codegen::qmlErrors() const { QList<QQmlError> qmlErrors; + + // Short circuit to avoid costly (de)heap allocation of QUrl if there are no errors. + if (_errors.size() == 0) + return qmlErrors; + qmlErrors.reserve(_errors.size()); QUrl url(_fileNameIsUrl ? QUrl(_module->fileName) : QUrl::fromLocalFile(_module->fileName)); |