comparison src/org/tmatesoft/hg/internal/IntVector.java @ 574:88afffd39899

Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 16 Apr 2013 14:44:57 +0200
parents e49f9d9513fa
children f41dd9a3b8af
comparison
equal deleted inserted replaced
573:e49f9d9513fa 574:88afffd39899
140 140
141 private void grow(int newCapacityHint) { 141 private void grow(int newCapacityHint) {
142 if (increment == 0) { 142 if (increment == 0) {
143 throw new UnsupportedOperationException("This vector is not allowed to expand"); 143 throw new UnsupportedOperationException("This vector is not allowed to expand");
144 } 144 }
145 int newCapacity = increment < 0 ? data.length << 1 : data.length + increment; 145 int newCapacity = increment < 0 ? data.length << 1 : (data.length + increment);
146 if (newCapacityHint > 0 && newCapacity < newCapacityHint) { 146 if (newCapacityHint > 0 && newCapacity < newCapacityHint) {
147 newCapacity = newCapacityHint; 147 newCapacity = newCapacityHint;
148 } 148 }
149 assert newCapacity > 0 && newCapacity != data.length : newCapacity; 149 assert newCapacity > 0 && newCapacity != data.length : newCapacity;
150 int[] newData = new int[newCapacity]; 150 int[] newData = new int[newCapacity];