533 |
|
int sc = (int)((1L + (4L * es) / 3) >>> SEGMENT_BITS); |
534 |
|
if (sc < MIN_SEGMENT_CAPACITY) |
535 |
|
sc = MIN_SEGMENT_CAPACITY; |
536 |
< |
else if (sc > MAX_SEGMENT_CAPACITY) |
537 |
< |
sc = MAX_SEGMENT_CAPACITY; |
538 |
< |
this.initialSegmentCapacity = sc; |
536 |
> |
int capacity = MIN_SEGMENT_CAPACITY; // ensure power of two |
537 |
> |
while (capacity < sc) |
538 |
> |
capacity <<= 1; |
539 |
> |
if (capacity > MAX_SEGMENT_CAPACITY) |
540 |
> |
capacity = MAX_SEGMENT_CAPACITY; |
541 |
> |
this.initialSegmentCapacity = capacity; |
542 |
|
} |
543 |
|
this.segments = (Segment[])new Segment[NSEGMENTS]; |
544 |
|
} |