ClangCodeModel: Save some disk space and unneeded allocations

... when writing out compile_commands.json files.

Change-Id: I8b2298eee87609a90ebb4dbd58b38bd6f36c5a7b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2022-10-07 13:25:53 +02:00
parent d659ace47f
commit eb59027920

View File

@@ -185,12 +185,12 @@ GenerateCompilationDbResult generateCompilationDB(QList<ProjectInfo::ConstPtr> p
optionsBuilder.isClStyle());
if (compileCommandsFile.size() > 1)
compileCommandsFile.write(",");
compileCommandsFile.write('\n' + QJsonDocument(json).toJson().trimmed());
compileCommandsFile.write(QJsonDocument(json).toJson(QJsonDocument::Compact));
}
}
}
compileCommandsFile.write("\n]");
compileCommandsFile.write("]");
compileCommandsFile.close();
return GenerateCompilationDbResult(compileCommandsFile.fileName(), QString());
}