- Keep the number of classes/interfaces to a minimum. Class overhead is over 200 bytes, so fancy OO designs with plenty of patterns and interfaces are not appropriate.
- Keep the number of methods to a minimum. Increasing member visibility eliminates the need for the usual get/set methods. Not very nice, but efficient.
- Try to use no more than 3 parameters for virtual methods and 4 for static methods. This way, the compiler will use a number or bytecode shortcuts, which help reduce code size: :aload_x (1 byte) instead of aload x (2 bytes), etc. (1 byte) instead of aload x (2 bytes), etc.
- Use the switch-case control structure with care. It generates very verbose bytecode.the switch-case control structure with care. It generates very verbose bytecode.
- Reuse local variables instead of declaring new ones. Reuse local variables instead of declaring new ones.
- Hunt down unused but initialized local variables. aload_ Hunt down unused but initialized local variables.







0 comments:
Post a Comment