private int calculateNewCapacity ( ) { int oldCapacity = queue . length ; int newCapacity = ( oldCapacity < 64 ) ? ( oldCapacity + 1 ) * 2 : IntMath . checkedMultiply ( oldCapacity / 2 , 3 ) ; return capAtMaximumSize ( newCapacity , maximumSize ) ; }
Returns ~2x the old capacity if small ; ~1 . 5x otherwise .