Maybe use Lucene's ArrayUtil#oversize(int, int) instead?