Performance optimization of getBounds()