diff options
author | Brian Vosburgh | 2015-07-20 21:13:07 +0000 |
---|---|---|
committer | Brian Vosburgh | 2015-07-20 21:13:07 +0000 |
commit | bea60fb811fcd78bf5e86d041a95106feb1d3160 (patch) | |
tree | 14e5bad843eb205111bf2f55c00451b2ad7f5557 /common | |
parent | d8c09ef8f40b9acf7054fb40eb8ddbd9aa0b3363 (diff) | |
download | webtools.dali-bea60fb811fcd78bf5e86d041a95106feb1d3160.tar.gz webtools.dali-bea60fb811fcd78bf5e86d041a95106feb1d3160.tar.xz webtools.dali-bea60fb811fcd78bf5e86d041a95106feb1d3160.zip |
simplify ArrayStack.copyElements(...) (!)
Diffstat (limited to 'common')
-rw-r--r-- | common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/ArrayStack.java | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/ArrayStack.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/ArrayStack.java index 1a51a188dc..e2a1d6b948 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/ArrayStack.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/ArrayStack.java @@ -113,20 +113,9 @@ public class ArrayStack<E> private E[] copyElements(int newCapacity) { @SuppressWarnings("unchecked") E[] newElements = (E[]) new Object[newCapacity]; - if (this.size != 0) { - Object oldElements[] = this.elements; - if (this.next >= this.size) { - // elements are contiguous, but not to end of array - System.arraycopy(oldElements, (this.next - this.size), newElements, 0, this.size); - } else if (this.next == 0) { - // elements are contiguous to end of array - System.arraycopy(oldElements, (oldElements.length - this.size), newElements, 0, this.size); - } else { - // elements wrap past end of array - int fragmentSize = this.size - this.next; - System.arraycopy(oldElements, (oldElements.length - fragmentSize), newElements, 0, fragmentSize); - System.arraycopy(oldElements, 0, newElements, fragmentSize, (this.size - fragmentSize)); - } + int len = this.size; + if (len != 0) { + System.arraycopy(this.elements, 0, newElements, 0, len); } return newElements; } |