Details
-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
-
b94
Description
CodeGenerator.initSymbols() is doing a destructive iteration over the list it gets. That's unnecessary. Should be rewritten as:
private void initSymbols(final LinkedList<Symbol> symbols, final Type type) {
final Iterator<Symbol> it = symbols.iterator();
if(it.hasNext()) {
method.loadUndefined(type);
boolean hasNext;
do {
final Symbol symbol = it.next();
hasNext = it.hasNext();
if(hasNext) {
method.dup();
}
method.store(symbol, type);
} while(hasNext);
}
}
private void initSymbols(final LinkedList<Symbol> symbols, final Type type) {
final Iterator<Symbol> it = symbols.iterator();
if(it.hasNext()) {
method.loadUndefined(type);
boolean hasNext;
do {
final Symbol symbol = it.next();
hasNext = it.hasNext();
if(hasNext) {
method.dup();
}
method.store(symbol, type);
} while(hasNext);
}
}