Java performance optimization

shape