ArrayList<EndData> endsChangedOld = null;
ArrayList<EndData> endsChangedNew = null;
Iterator<Port> pit = ports.iterator();
for (int i = 0; pit.hasNext() || i < esOldLength; i++) {
Port p = pit.hasNext() ? pit.next() : null;
EndData oldEnd = i < esOldLength ? esOld[i] : null;
EndData newEnd = p == null ? null : p.toEnd(loc, attrs);
if (oldEnd == null || !oldEnd.equals(newEnd)) {
if (newEnd != null) es[i] = newEnd;
if (endsChangedOld == null) {
endsChangedOld = new ArrayList<EndData>();
endsChangedNew = new ArrayList<EndData>();