Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
99b64924
Commit
99b64924
authored
Jul 19, 2010
by
Roberto Raggi
Browse files
Reduce the CPU usage of the semantic highlighter.
parent
867bf3da
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppchecksymbols.cpp
View file @
99b64924
...
...
@@ -51,6 +51,12 @@ using namespace CppEditor::Internal;
namespace
{
class
FriendlyThread
:
public
QThread
{
public:
using
QThread
::
msleep
;
};
class
CollectTypes
:
protected
SymbolVisitor
{
Document
::
Ptr
_doc
;
...
...
@@ -281,6 +287,7 @@ protected:
CheckSymbols
::
Future
CheckSymbols
::
go
(
Document
::
Ptr
doc
,
const
LookupContext
&
context
)
{
Q_ASSERT
(
doc
);
return
(
new
CheckSymbols
(
doc
,
context
))
->
start
();
}
...
...
@@ -300,21 +307,17 @@ CheckSymbols::~CheckSymbols()
{
}
void
CheckSymbols
::
run
()
{
if
(
!
isCanceled
())
runFunctor
();
reportFinished
();
}
void
CheckSymbols
::
runFunctor
()
{
_diagnosticMessages
.
clear
();
if
(
_doc
->
translationUnit
())
{
accept
(
_doc
->
translationUnit
()
->
ast
());
flush
();
if
(
!
isCanceled
())
{
if
(
_doc
->
translationUnit
())
{
accept
(
_doc
->
translationUnit
()
->
ast
());
flush
();
}
}
reportFinished
();
}
bool
CheckSymbols
::
warning
(
unsigned
line
,
unsigned
column
,
const
QString
&
text
,
unsigned
length
)
...
...
@@ -687,6 +690,7 @@ void CheckSymbols::flush()
if
(
_usages
.
isEmpty
())
return
;
FriendlyThread
::
msleep
(
10
);
// release some cpu
reportResults
(
_usages
);
_usages
.
clear
();
}
src/plugins/cppeditor/cppchecksymbols.h
View file @
99b64924
...
...
@@ -43,7 +43,8 @@ namespace CPlusPlus {
class
CheckSymbols
:
protected
ASTVisitor
,
public
QtConcurrent
::
RunFunctionTaskBase
<
CppEditor
::
Internal
::
SemanticInfo
::
Use
>
public
QRunnable
,
public
QFutureInterface
<
CppEditor
::
Internal
::
SemanticInfo
::
Use
>
{
public:
virtual
~
CheckSymbols
();
...
...
@@ -51,9 +52,18 @@ public:
typedef
CppEditor
::
Internal
::
SemanticInfo
::
Use
Use
;
virtual
void
run
();
void
runFunctor
();
typedef
QFuture
<
Use
>
Future
;
Future
start
()
{
this
->
setRunnable
(
this
);
this
->
reportStarted
();
Future
future
=
this
->
future
();
QThreadPool
::
globalInstance
()
->
start
(
this
,
QThread
::
IdlePriority
);
return
future
;
}
static
Future
go
(
Document
::
Ptr
doc
,
const
LookupContext
&
context
);
static
QMap
<
int
,
QVector
<
Use
>
>
chunks
(
const
QFuture
<
Use
>
&
future
,
int
from
,
int
to
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment