equal
deleted
inserted
replaced
98 * method takes no action and simply returns. |
98 * method takes no action and simply returns. |
99 * |
99 * |
100 * @param minimumCapacity the minimum desired capacity. |
100 * @param minimumCapacity the minimum desired capacity. |
101 */ |
101 */ |
102 public void ensureCapacity(int minimumCapacity) { |
102 public void ensureCapacity(int minimumCapacity) { |
103 ensureCapacityInternal(minimumCapacity); |
103 if (minimumCapacity > 0) |
|
104 ensureCapacityInternal(minimumCapacity); |
104 } |
105 } |
105 |
106 |
106 /** |
107 /** |
107 * This method has the same contract as ensureCapacity, but is |
108 * This method has the same contract as ensureCapacity, but is |
108 * never synchronized. |
109 * never synchronized. |
109 */ |
110 */ |
110 private void ensureCapacityInternal(int minimumCapacity) { |
111 private void ensureCapacityInternal(int minimumCapacity) { |
|
112 // overflow-conscious code |
111 if (minimumCapacity - value.length > 0) |
113 if (minimumCapacity - value.length > 0) |
112 expandCapacity(minimumCapacity); |
114 expandCapacity(minimumCapacity); |
113 } |
115 } |
114 |
116 |
115 /** |
117 /** |