Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2004-05-28 15:02:32 -0400
committerAndrew Niefer2004-05-28 15:02:32 -0400
commit495d77744bf92f596e88fbaffb336e4cbe4deb29 (patch)
tree6a94948c428af5fe233fc72f63a665b51a78d212
parent1b8740f2d35030d5472a5202f3ef59320eecbc0c (diff)
downloadorg.eclipse.cdt-495d77744bf92f596e88fbaffb336e4cbe4deb29.tar.gz
org.eclipse.cdt-495d77744bf92f596e88fbaffb336e4cbe4deb29.tar.xz
org.eclipse.cdt-495d77744bf92f596e88fbaffb336e4cbe4deb29.zip
reduce the use of iterators in the symbol table
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java78
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java8
10 files changed, 112 insertions, 123 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java
index 7555c1a218..5fb0d3c69b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java
@@ -686,12 +686,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
//collect associated namespaces & classes.
int size = ( parameters == null ) ? 0 : parameters.size();
- Iterator iter = ( parameters == null ) ? null : parameters.iterator();
-
+
TypeInfo param = null;
ISymbol paramType = null;
- for( int i = size; i > 0; i-- ){
- param = (TypeInfo) iter.next();
+ for( int i = 0; i < size; i++ ){
+ param = (TypeInfo) parameters.get(i);
paramType = ParserSymbolTable.getFlatTypeInfo( param ).getTypeSymbol();
if( paramType == null ){
@@ -703,7 +702,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
//if T is a pointer to a data member of class X, its associated namespaces and classes
//are those associated with the member type together with those associated with X
if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){
- TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().iterator().next();
+ TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().get(0);
if( op.getType() == TypeInfo.PtrOp.t_pointer &&
paramType.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) )
{
@@ -994,9 +993,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
IDerivableContainerSymbol derivable = (IDerivableContainerSymbol) symbol;
- Iterator iter = derivable.getFriends().iterator();
- while( iter.hasNext() ){
- ISymbol friend = (ISymbol) iter.next();
+ List friends = derivable.getFriends();
+ int size = friends.size();
+ for( int i = 0; i < size; i++ ){
+ ISymbol friend = (ISymbol) friends.get(i);
ISymbol typeSymbol = friend.getTypeSymbol();
if( friend == this || typeSymbol == this ||
friend == container || ( container != null && typeSymbol == container ) )
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
index 38ba8371f1..1234901fad 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
@@ -51,10 +51,9 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
List args = getArguments();
List newArgs = new ArrayList( args.size() );
- Iterator iter = args.iterator();
-
- while( iter.hasNext() ){
- TypeInfo arg = (TypeInfo) iter.next();
+ int size = args.size();
+ for( int i = 0; i < size; i++ ){
+ TypeInfo arg = (TypeInfo) args.get(i);
newArgs.add( TemplateEngine.instantiateTypeInfo( arg, template, argMap ) );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java
index 419cbb42ad..8e9c5d7a12 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java
@@ -62,12 +62,12 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
DerivableContainerSymbol newSymbol = (DerivableContainerSymbol) super.instantiate( template, argMap );
- Iterator parents = getParents().iterator();
-
+ List parents = getParents();
+ int size = parents.size();
newSymbol.getParents().clear();
ParentWrapper wrapper = null;
- while( parents.hasNext() ){
- wrapper = (ParentWrapper) parents.next();
+ for( int i = 0; i < size; i++ ){
+ wrapper = (ParentWrapper) parents.get(i);
ISymbol parent = wrapper.getParent();
if( parent == null )
continue;
@@ -87,10 +87,11 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
}
public void instantiateDeferredParent( ISymbol parent, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
- Iterator parents = getParents().iterator();
+ List parents = getParents();
+ int size = parents.size();
ParentWrapper w = null;
- while( parents.hasNext() ) {
- w = (ParentWrapper) parents.next();
+ for( int i = 0; i < size; i++ ){
+ w = (ParentWrapper) parents.get(i);
if( w.getParent() == parent ){
w.setParent( parent.instantiate( template, argMap ) );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java
index 9834fac91a..16957dba39 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java
@@ -82,15 +82,16 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
//handle template parameter lists in TemplateSymbol, only do function parameter lists here.
if( !isType( TypeInfo.t_template ) ){
- Iterator iter = getParameterList().iterator();
+ List params = getParameterList();
+ int size = params.size();
newParameterized.getParameterList().clear();
newParameterized.getParameterMap().clear();
ISymbol param = null, newParam = null;
- while( iter.hasNext() ){
- param = (ISymbol) iter.next();
+ for( int i = 0; i < size; i++ ){
+ param = (ISymbol) params.get(i);
newParam = param.instantiate( template, argMap );
newParameterized.addParameter( newParam );
@@ -211,15 +212,15 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
if( fsize == 0 )
return true;
- Iterator iter = getParameterList().iterator();
- Iterator fIter = function.getParameterList().iterator();
+ List params = getParameterList();
+ List functionParams = function.getParameterList();
TypeInfo info = null;
TypeInfo fInfo = null;
- for( int i = size; i > 0; i-- ){
- ISymbol p = (ISymbol) iter.next();
- ISymbol pf = (ISymbol) fIter.next();
+ for( int i = 0; i < size; i++ ){
+ ISymbol p = (ISymbol) params.get(i);
+ ISymbol pf = (ISymbol) functionParams.get(i);
info = p.getTypeInfo();
fInfo = pf.getTypeInfo();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
index 576f20b665..92c63a9c37 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
@@ -826,7 +826,7 @@ public class ParserSymbolTable {
protected static boolean isValidOverload( List origList, ISymbol newSymbol ){
if( origList.size() == 1 ){
- return isValidOverload( (ISymbol)origList.iterator().next(), newSymbol );
+ return isValidOverload( (ISymbol)origList.get(0), newSymbol );
} else if ( origList.size() > 1 ){
if( newSymbol.isType( TypeInfo.t_template ) ){
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
@@ -840,18 +840,18 @@ public class ParserSymbolTable {
return false;
}
- Iterator iter = origList.iterator();
- ISymbol symbol = (ISymbol) iter.next();
-
+ //Iterator iter = origList.iterator();
+ ISymbol symbol = (ISymbol) origList.get(0);
+ int numSymbols = origList.size();
if( symbol.isType( TypeInfo.t_template ) ){
IParameterizedSymbol template = (IParameterizedSymbol) symbol;
symbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
}
boolean valid = isValidOverload( symbol, newSymbol );
-
- while( valid && iter.hasNext() ){
- symbol = (ISymbol) iter.next();
+ int idx = 1;
+ while( valid && idx < numSymbols ){
+ symbol = (ISymbol) origList.get(idx++);
if( symbol.isType( TypeInfo.t_template ) ){
ITemplateSymbol template = (ITemplateSymbol) symbol;
symbol = template.getTemplatedSymbol();
@@ -990,7 +990,7 @@ public class ParserSymbolTable {
if( numFns == 0 ){
return null;
} else if ( numFns == 1 ){
- return (IParameterizedSymbol)functions.iterator().next();
+ return (IParameterizedSymbol)functions.get(0);
} else if ( numFns == 2 ){
for (int i = 0; i < numFns; i++) {
IParameterizedSymbol fn = (IParameterizedSymbol) functions.get(i);
@@ -1250,12 +1250,12 @@ public class ParserSymbolTable {
}
//check for void
else if( numParameters == 0 && num == 1 ){
- ISymbol param = (ISymbol)function.getParameterList().iterator().next();
+ ISymbol param = (ISymbol)function.getParameterList().get(0);
if( param.isType( TypeInfo.t_void ) )
continue;
}
else if( numParameters == 1 && num == 0 ){
- TypeInfo paramType = (TypeInfo) data.getParameters().iterator().next();
+ TypeInfo paramType = (TypeInfo) data.getParameters().get(0);
if( paramType.isType( TypeInfo.t_void ) )
continue;
}
@@ -1399,11 +1399,11 @@ public class ParserSymbolTable {
IDerivableContainerSymbol parent = null;
IDerivableContainerSymbol.IParentSymbol wrapper;
- Iterator iter = symbol.getParents().iterator();
- int size = symbol.getParents().size();
+ List parents = symbol.getParents();
+ int size = parents.size();
- for( int i = size; i > 0; i-- ){
- wrapper = (IDerivableContainerSymbol.IParentSymbol) iter.next();
+ for( int i = 0; i < size; i++ ){
+ wrapper = (IDerivableContainerSymbol.IParentSymbol) parents.get(i);
temp = wrapper.getParent();
boolean isVisible = ( wrapper.getAccess() == ASTAccessVisibility.PUBLIC );
if ( temp instanceof IDerivableContainerSymbol ){
@@ -2271,13 +2271,13 @@ public void setLanguage( ParserLanguage language ){
}
List parents = ((IDerivableContainerSymbol) qualifyingSymbol).getParents();
- Iterator iter = parents.iterator();
+ int numParents = parents.size();
IParentSymbol parent = null;
ASTAccessVisibility symbolAccess = null;
ASTAccessVisibility parentAccess = null;
- while( iter.hasNext() ){
- parent = (IParentSymbol) iter.next();
+ for( int i = 0; i < numParents; i++ ){
+ parent = (IParentSymbol) parents.get(i);
if( container == parent.getParent() ){
parentAccess = parent.getAccess();
@@ -2287,14 +2287,12 @@ public void setLanguage( ParserLanguage language ){
}
}
- iter = parents.iterator();
-
//if static or an enumerator, the symbol could be visible through more than one path through the heirarchy,
//so we need to check all paths
boolean checkAllPaths = ( symbol.isType( TypeInfo.t_enumerator ) || symbol.getTypeInfo().checkBit( TypeInfo.isStatic ) );
ASTAccessVisibility resultingAccess = null;
- while( iter.hasNext() ){
- parent = (IParentSymbol) iter.next();
+ for( int i = 0; i < numParents; i++ ){
+ parent = (IParentSymbol) parents.get(i);
parentAccess = parent.getAccess();
ISymbol tmp = parent.getParent();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java
index 591c9f1f90..7f181e4601 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java
@@ -60,17 +60,15 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
List actualArgs = new ArrayList( specArgs.size() );
- Iterator iter1 = specArgs.iterator();
- Iterator iter2 = arguments.iterator();
-
ISymbol templatedSymbol = getTemplatedSymbol();
while( templatedSymbol.isTemplateInstance() ){
templatedSymbol = templatedSymbol.getInstantiatedSymbol();
}
- while( iter1.hasNext() ){
- TypeInfo info = (TypeInfo) iter1.next();
- TypeInfo mappedInfo = (TypeInfo) iter2.next();
+ int numSpecArgs = specArgs.size();
+ for( int i = 0; i < numSpecArgs; i++ ){
+ TypeInfo info = (TypeInfo) specArgs.get(i);
+ TypeInfo mappedInfo = (TypeInfo) arguments.get(i);
//If the argument is a template parameter, we can't instantiate yet, defer for later
if( mappedInfo.isType( TypeInfo.t_type ) && mappedInfo.getTypeSymbol().isType( TypeInfo.t_templateParameter ) ){
@@ -93,9 +91,10 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
if( getParameterList().size() != argMap.size() )
return null;
- Iterator params = getParameterList().iterator();
- while( params.hasNext() ){
- if( !argMap.containsKey( params.next() ) )
+ List params = getParameterList();
+ int numParams = params.size();
+ for( int i = 0; i < numParams; i++ ){
+ if( !argMap.containsKey( params.get(i) ) )
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java
index 8e5de5cc7b..ea37d5ffcb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java
@@ -82,26 +82,23 @@ public final class TemplateEngine {
ISpecializedSymbol bestMatch = null;
boolean bestMatchIsBest = true;
- Iterator iter = specs.iterator();
ISpecializedSymbol spec = null;
List specArgs = null;
- for( int i = size; i > 0; i-- ){
- spec = (ISpecializedSymbol) iter.next();
+ for( int i = 0; i < size; i++ ){
+ spec = (ISpecializedSymbol) specs.get(i);
specArgs = spec.getArgumentList();
if( specArgs == null || specArgs.size() != args.size() ){
continue;
}
- Iterator iter1 = specArgs.iterator();
- Iterator iter2 = args.iterator();
-
+ int specArgsSize = specArgs.size();
HashMap map = new HashMap();
TypeInfo info1 = null, info2 = null;
boolean match = true;
- for( int j = specArgs.size(); j > 0; j-- ){
- info1 = (TypeInfo) iter1.next();
- info2 = (TypeInfo) iter2.next();
+ for( int j = 0; j < specArgsSize; j++ ){
+ info1 = (TypeInfo) specArgs.get(j);
+ info2 = (TypeInfo) args.get(j);
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
sym1.setTypeInfo( info1 );
@@ -150,16 +147,14 @@ public final class TemplateEngine {
List pList = p.getParameterList();
List aList = a.getParameterList();
-
- if( pList.size() != aList.size() ){
+ int size = pList.size();
+ if( aList.size() != size){
return false;
}
- Iterator pIter = pList.iterator();
- Iterator aIter = aList.iterator();
- while( pIter.hasNext() ){
- ISymbol pParam = (ISymbol) pIter.next();
- ISymbol aParam = (ISymbol) aIter.next();
+ for( int i = 0; i < size; i++){
+ ISymbol pParam = (ISymbol) pList.get(i);
+ ISymbol aParam = (ISymbol) aList.get(i);
if( pParam.getType() != aParam.getType() ||
pParam.getTypeInfo().getTemplateParameterType() != aParam.getTypeInfo().getTemplateParameterType() )
@@ -521,7 +516,7 @@ public final class TemplateEngine {
List pPtrs = p.getPtrOperators();
if( pPtrs.size() != 0 ){
- PtrOp op = (PtrOp) pPtrs.iterator().next();
+ PtrOp op = (PtrOp) pPtrs.get(0);
if( op.getType() == PtrOp.t_memberPointer ){
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
@@ -889,12 +884,13 @@ public final class TemplateEngine {
if( map == null )
continue;
- Iterator paramIter = template.getParameterList().iterator();
- Iterator argsIter = (templateArguments != null ) ? templateArguments.iterator() : null;
- List instanceArgs = new ArrayList( template.getParameterList().size() );
- while( paramIter.hasNext() ){
- ISymbol param = (ISymbol) paramIter.next();
- TypeInfo arg = (TypeInfo) (( argsIter != null && argsIter.hasNext() )? argsIter.next() : null);
+ List templateParams = template.getParameterList();
+ int numTemplateParams = templateParams.size();
+ int numTemplateArgs = ( templateArguments != null ) ? templateArguments.size() : 0;
+ List instanceArgs = new ArrayList( templateParams.size() );
+ for( int i = 0; i < numTemplateParams; i++ ){
+ ISymbol param = (ISymbol) templateParams.get(i);
+ TypeInfo arg = (TypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null);
TypeInfo mapped = (TypeInfo) map.get( param );
if( arg != null && mapped != null )
@@ -937,10 +933,9 @@ public final class TemplateEngine {
if( arguments.size() != parameters.size() ){
forPrimary = false;
} else if( !parameters.isEmpty() ){
- Iterator pIter = parameters.iterator();
- Iterator aIter = arguments.iterator();
- while( pIter.hasNext() ){
- if( pIter.next() != ((TypeInfo) aIter.next()).getTypeSymbol() ){
+ int size = parameters.size();
+ for( int i = 0; i < size; i++ ){
+ if( parameters.get(i) != ((TypeInfo) arguments.get(i)).getTypeSymbol() ){
forPrimary = false;
break;
}
@@ -1156,14 +1151,14 @@ public final class TemplateEngine {
static protected List verifyExplicitArguments( ITemplateSymbol template, List arguments, ISymbol symbol ) throws ParserSymbolTableException{
List params = template.getParameterList();
- Iterator args = arguments.iterator();
int numParams = params.size();
+ int numArgs = arguments.size();
List actualArgs = new ArrayList( numParams );
for( int i = 0; i < numParams; i++ ){
ISymbol param = (ISymbol) params.get(i);
- if( args.hasNext() ){
- TypeInfo arg = (TypeInfo) args.next();
+ if( i < numArgs ){
+ TypeInfo arg = (TypeInfo) arguments.get(i);
if( matchTemplateParameterAndArgument( param, arg ) ){
actualArgs.add( arg );
} else {
@@ -1200,11 +1195,12 @@ public final class TemplateEngine {
if( map == null )
continue;
- Iterator pIter = tmpl.getParameterList().iterator();
- Iterator aIter = args.iterator();
- while( pIter.hasNext() && aIter.hasNext() ){
- ISymbol param = (ISymbol) pIter.next();
- TypeInfo arg = (TypeInfo) aIter.next();
+ List params = tmpl.getParameterList();
+ int numParams = params.size();
+ int numArgs = args.size();
+ for( int i = 0; i < numParams && i < numArgs; i++ ){
+ ISymbol param = (ISymbol) params.get(i);
+ TypeInfo arg = (TypeInfo) args.get(i);
if( map.containsKey( param ) ) {
if( !map.get( param ).equals( arg )){
continue outer;
@@ -1230,13 +1226,13 @@ public final class TemplateEngine {
List params = template.getParameterList();
Map map = null;
- Iterator pIter = params.iterator();
- Iterator aIter = ( args != null ) ? args.iterator() : null;
- while( pIter.hasNext() ){
- ISymbol param = (ISymbol) pIter.next();
+ int numParams = params.size();
+ int numArgs = ( args != null ) ? args.size() : 0;
+ for( int i = 0; i < numParams; i++ ){
+ ISymbol param = (ISymbol) params.get(i);
TypeInfo arg = null;
- if( aIter != null && aIter.hasNext() ){
- arg = (TypeInfo) aIter.next();
+ if( i < numArgs ){
+ arg = (TypeInfo) args.get(i);
} else {
if( map == null ){
map = deduceTemplateArgumentsUsingParameterList( template, fn );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java
index 56ab51d257..4a1c54197b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java
@@ -512,23 +512,22 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
}
private ITemplateSymbol getNextAvailableTemplate() throws ParserSymbolTableException{
- Iterator tIter = templates.iterator();
- Iterator sIter = symbols.iterator();
-
- while( sIter.hasNext() ){
- ISymbol symbol = (ISymbol) sIter.next();
+ int numSymbols = symbols.size();
+ int numTemplates = templates.size();
+ int templateIdx = 0;
+ for( int i = 0; i < numSymbols; i++ ){
+ ISymbol symbol = (ISymbol) symbols.get(i);
if( symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
- if( tIter.hasNext() )
- tIter.next();
+ if( templateIdx < numTemplates )
+ templateIdx++;
else
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
-
}
}
- if( !tIter.hasNext() )
+ if( templateIdx >= numTemplates )
return null;
- return (ITemplateSymbol) tIter.next();
+ return (ITemplateSymbol) templates.get( templateIdx );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
index 2169082a1a..06d06e5af5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
@@ -76,18 +76,15 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
List paramList = template.getParameterList();
int numParams = ( paramList != null ) ? paramList.size() : 0;
+ int numArgs = arguments.size();
if( numParams == 0 ){
return null;
}
HashMap map = new HashMap();
- Iterator paramIter = paramList.iterator();
- Iterator argIter = arguments.iterator();
-
ISymbol param = null;
TypeInfo arg = null;
-
List actualArgs = new ArrayList( numParams );
ISymbol templatedSymbol = template.getTemplatedSymbol();
@@ -96,12 +93,12 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
}
for( int i = 0; i < numParams; i++ ){
- param = (ISymbol) paramIter.next();
+ param = (ISymbol) paramList.get(i);
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
- if( argIter.hasNext() ){
- arg = (TypeInfo) argIter.next();
+ if( i < numArgs ){
+ arg = (TypeInfo) arguments.get(i);
//If the argument is a template parameter, we can't instantiate yet, defer for later
if( arg.isType( TypeInfo.t_type ) ){
if( arg.getTypeSymbol() == null )
@@ -166,10 +163,11 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
TemplateSymbol newTemplate = (TemplateSymbol) super.instantiate( template, argMap );
//we don't want to instantiate the template parameters, just the defaults if there are any
- Iterator iter = newTemplate.getParameterList().iterator();
+ List parameters = newTemplate.getParameterList();
+ int size = parameters.size();
ISymbol param = null;
- while( iter.hasNext() ){
- param = (ISymbol) iter.next();
+ for( int i = 0; i < size; i++ ){
+ param = (ISymbol) parameters.get(i);
Object obj = param.getTypeInfo().getDefault();
if( obj instanceof TypeInfo ){
param.getTypeInfo().setDefault( TemplateEngine.instantiateTypeInfo( (TypeInfo) obj, template, argMap ) );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java
index 737f0ee6a6..0531d5e049 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java
@@ -330,15 +330,13 @@ public class TypeInfo {
public boolean hasSamePtrs( TypeInfo type ){
int size = getPtrOperators().size();
int size2 = type.getPtrOperators().size();
- Iterator iter1 = getPtrOperators().iterator();
- Iterator iter2 = type.getPtrOperators().iterator();
TypeInfo.PtrOp ptr1 = null, ptr2 = null;
if( size == size2 ){
if( size > 0 ){
- for( int i = size; i > 0; i-- ){
- ptr1 = (TypeInfo.PtrOp)iter1.next();
- ptr2 = (TypeInfo.PtrOp)iter2.next();
+ for( int i = 0; i < size; i++ ){
+ ptr1 = (TypeInfo.PtrOp)getPtrOperators().get(i);
+ ptr2 = (TypeInfo.PtrOp)type.getPtrOperators().get(i);
if( ptr1.getType() != ptr2.getType() ){
return false;
}

Back to the top