Class MemberFieldRewriter

  • All Implemented Interfaces:
    CodeRewriter

    @Internal
    public class MemberFieldRewriter
    extends Object
    implements CodeRewriter
    Group member variables with the same type into arrays to reduce the number of members.

    Before

    
     public class Example {
         int a;
         long b;
         int c = 1;
         long d = 2;
         public void myFun() {
             System.out.println(a + b + c + d);
         }
     }
     

    After

    
     public class Example {
         int[] rewrite$0 = new int[2];
         long[] rewrite$1 = new long[2];
         {
             rewrite$0[1] = 1;
             rewrite$1[1] = 2;
         }
         public void myFun() {
             System.out.println(rewrite$0[0] + rewrite$1[0] + rewrite$0[1] + rewrite$1[1]);
         }
     }
     
    • Constructor Detail

      • MemberFieldRewriter

        public MemberFieldRewriter​(String code,
                                   int maxFieldCount)