mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 513280 - Major performance inefficiency in CPPVariable.getType
In my test project this change reduced total indexing time by half. Change-Id: I6c7d3adfa1e4d2d05f7f5108f25110f6a9ec9a1a
This commit is contained in:
parent
87c75513e0
commit
35e7ae3e05
4 changed files with 36 additions and 2 deletions
|
@ -54,7 +54,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPVariable extends PlatformObject implements ICPPInternalVariable {
|
||||
public class CPPVariable extends PlatformObject implements ICPPInternalDeclaredVariable {
|
||||
private IASTName fDefinition;
|
||||
private IASTName fDeclarations[];
|
||||
private IType fType;
|
||||
|
@ -327,4 +327,9 @@ public class CPPVariable extends PlatformObject implements ICPPInternalVariable
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allDeclarationsDefinitionsAdded() {
|
||||
fAllResolved = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
public class CPPVariableTemplate extends CPPTemplateDefinition
|
||||
implements ICPPVariableTemplate, ICPPInternalVariable {
|
||||
implements ICPPVariableTemplate, ICPPInternalDeclaredVariable {
|
||||
private IType fType;
|
||||
private boolean fAllResolved;
|
||||
private ICPPPartialSpecialization[] partialSpecializations = ICPPPartialSpecialization.EMPTY_ARRAY;
|
||||
|
@ -100,4 +100,9 @@ public class CPPVariableTemplate extends CPPTemplateDefinition
|
|||
public void addPartialSpecialization(ICPPPartialSpecialization partSpec) {
|
||||
partialSpecializations = ArrayUtil.append(partialSpecializations, partSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allDeclarationsDefinitionsAdded() {
|
||||
fAllResolved = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
public interface ICPPInternalDeclaredVariable extends ICPPInternalVariable {
|
||||
/**
|
||||
* Informs the variable that all its declarations and definitions have already been added.
|
||||
*/
|
||||
public void allDeclarationsDefinitionsAdded();
|
||||
}
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeclaredVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
|
@ -48,6 +49,11 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
Database db = getDB();
|
||||
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotations.encodeVariableAnnotations(variable));
|
||||
if (setTypeAndValue) {
|
||||
if (variable instanceof ICPPInternalDeclaredVariable) {
|
||||
// By the time PDOMCPPVariable is created all declarations and definitions have already been
|
||||
// added to the variable.
|
||||
((ICPPInternalDeclaredVariable) variable).allDeclarationsDefinitionsAdded();
|
||||
}
|
||||
setType(parent.getLinkage(), variable.getType());
|
||||
linkage.new ConfigureVariable(variable, this);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue