mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 03:05:39 +02:00
Bug 513345 - A lot of time during indexing is spent inside
CompositeValue.create Added precalculation of initial values of non-field variables. Change-Id: Ie6c0690d90d5725e812d10afa15c4a11ba92f647
This commit is contained in:
parent
7501266165
commit
5b22093f47
1 changed files with 14 additions and 6 deletions
|
@ -45,10 +45,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
@ -358,7 +360,7 @@ public abstract class PDOMWriter implements IPDOMASTProcessor {
|
||||||
|
|
||||||
private void resolveNames(Data data, IProgressMonitor monitor) {
|
private void resolveNames(Data data, IProgressMonitor monitor) {
|
||||||
long start= System.currentTimeMillis();
|
long start= System.currentTimeMillis();
|
||||||
List<ICPPInternalDeclaredVariable> variables = new ArrayList<>();
|
Set<ICPPInternalDeclaredVariable> variables = new HashSet<>();
|
||||||
SubMonitor progress = SubMonitor.convert(monitor, data.fSelectedFiles.length);
|
SubMonitor progress = SubMonitor.convert(monitor, data.fSelectedFiles.length);
|
||||||
for (FileInAST file : data.fSelectedFiles) {
|
for (FileInAST file : data.fSelectedFiles) {
|
||||||
Symbols symbols= data.fSymbolMap.get(file.includeStatement);
|
Symbols symbols= data.fSymbolMap.get(file.includeStatement);
|
||||||
|
@ -419,14 +421,11 @@ public abstract class PDOMWriter implements IPDOMASTProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Precalculate types and initial values of all fields to avoid doing it later when writing
|
// Precalculate types and initial values of all indexed variables to avoid doing it later when writing
|
||||||
// to the index.
|
// to the index.
|
||||||
for (ICPPInternalDeclaredVariable variable : variables) {
|
for (ICPPInternalDeclaredVariable variable : variables) {
|
||||||
variable.allDeclarationsDefinitionsAdded();
|
variable.allDeclarationsDefinitionsAdded();
|
||||||
// TODO(sprigogin): It would be beneficial to precalculate types and initial values of all
|
if (isVariableIndexed(variable)) {
|
||||||
// indexed variables not just fields. It should be done carefully to avoid
|
|
||||||
// unnecesssary overhead of doing it for variables that are not being indexed.
|
|
||||||
if (variable instanceof ICPPField) {
|
|
||||||
// Type and initial value will be cached by the variable.
|
// Type and initial value will be cached by the variable.
|
||||||
variable.getType();
|
variable.getType();
|
||||||
variable.getInitialValue();
|
variable.getInitialValue();
|
||||||
|
@ -436,6 +435,15 @@ public abstract class PDOMWriter implements IPDOMASTProcessor {
|
||||||
fStatistics.fResolutionTime += System.currentTimeMillis() - start;
|
fStatistics.fResolutionTime += System.currentTimeMillis() - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVariableIndexed(ICPPVariable variable) {
|
||||||
|
if (variable instanceof ICPPField)
|
||||||
|
return true;
|
||||||
|
IBinding owner = variable.getOwner();
|
||||||
|
if (owner == null || owner instanceof IASTTranslationUnit || owner instanceof ICPPNamespace)
|
||||||
|
return true;
|
||||||
|
return owner instanceof ICPPFunction && ((ICPPFunction) owner).isConstexpr();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int process(final IASTTranslationUnit ast, final IIndexSymbols symbols) throws CoreException {
|
public int process(final IASTTranslationUnit ast, final IIndexSymbols symbols) throws CoreException {
|
||||||
if (!(symbols instanceof Data)) {
|
if (!(symbols instanceof Data)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue