forked from qt-creator/qt-creator
ClangFormat: Add caching of current style
Previously, ClangFormat was getting the style for a file every time styleForFile was called, which could cause unnecessary delays and impact performance. This commit adds caching of the current style with a timeout of 1s, so that ClangFormat can quickly access the cached style instead of recalculating it each time. Change-Id: I33c114d51d6ce1acd0b6d9d2a28e2b6712e149dd Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -31,7 +31,7 @@ using namespace Utils;
|
||||
|
||||
namespace ClangFormat {
|
||||
|
||||
clang::format::FormatStyle qtcStyle()
|
||||
clang::format::FormatStyle calculateQtcStyle()
|
||||
{
|
||||
clang::format::FormatStyle style = getLLVMStyle();
|
||||
style.Language = FormatStyle::LK_Cpp;
|
||||
@@ -179,6 +179,12 @@ clang::format::FormatStyle qtcStyle()
|
||||
return style;
|
||||
}
|
||||
|
||||
clang::format::FormatStyle qtcStyle()
|
||||
{
|
||||
static clang::format::FormatStyle style = calculateQtcStyle();
|
||||
return style;
|
||||
}
|
||||
|
||||
QString projectUniqueId(ProjectExplorer::Project *project)
|
||||
{
|
||||
if (!project)
|
||||
|
||||
Reference in New Issue
Block a user