Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBrian Vosburgh2015-07-20 21:13:07 +0000
committerBrian Vosburgh2015-07-20 21:13:07 +0000
commitbea60fb811fcd78bf5e86d041a95106feb1d3160 (patch)
tree14e5bad843eb205111bf2f55c00451b2ad7f5557 /common
parentd8c09ef8f40b9acf7054fb40eb8ddbd9aa0b3363 (diff)
downloadwebtools.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.java17
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;
}

Back to the top