Optimize content size calculation