Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8015674

CodeGenerator.initSymbols mutates a list

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • None
    • core-libs
    • None

    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);
              }
          }

      Attachments

        Activity

          People

            attila Attila Szegedi
            attila Attila Szegedi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: