# HG changeset patch
# User attila
# Date 1369997864 -7200
# Node ID 0a4ddfce5b849b5710048a81612fe89651353326
# Parent  108ba976aa02193cb61fd2ae6397f192a0bd1aa4
8015674: CodeGenerator.initSymbols mutates a list
Reviewed-by: jlaskey, lagergren

diff -r 108ba976aa02 -r 0a4ddfce5b84 nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri May 31 12:57:25 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri May 31 12:57:44 2013 +0200
@@ -456,17 +456,18 @@
     }
 
     private void initSymbols(final LinkedList<Symbol> symbols, final Type type) {
-        if (symbols.isEmpty()) {
-            return;
-        }
-
-        method.loadUndefined(type);
-        while (!symbols.isEmpty()) {
-            final Symbol symbol = symbols.removeFirst();
-            if (!symbols.isEmpty()) {
-                method.dup();
-            }
-            method.store(symbol);
+        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);
+            } while(hasNext);
         }
     }