It might be better to try and reuse the existing long[] array, if it is big enough, rather than creating a new one. Depends on how often a change is done of course, so maybe premature optimization now.