diff options
-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)); |