Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-1070

MarshallerGeneratorFactory optimization

    Details

    • Type: Enhancement
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.1.Beta1
    • Fix Version/s: master
    • Component/s: ErraiMarshalling
    • Labels:
      None
    • Estimated Difficulty:
      Medium

      Description

      MarshallerFactoryImpl code generated by MarshallerGeneratorFactory is inefficient, because it uses if-then-else in loadMarshaller() method. When replaced by switch, resulting js code size went down from 20kb to 13kb in my current project. After my changes new code for loadMarshaller() looks like this (I will open pull request soon):

        private boolean putMarshaller(String fqcn, Marshaller m) {
          marshallers.put(fqcn, m);
          return true;
        }
       
        private boolean loadMarshaller0(String a0) {
          switch (a0) {
            case "java.lang.Throwable": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_Throwable.class));
            case "java.lang.ArithmeticException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_ArithmeticException.class));
            case "java.io.IOException": return putMarshaller(a0, GWT.create(Marshaller_for_java_io_IOException.class));
            case "java.lang.IllegalArgumentException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_IllegalArgumentException.class));
            case "java.util.EmptyStackException": return putMarshaller(a0, GWT.create(Marshaller_for_java_util_EmptyStackException.class));
            case "java.lang.ArrayStoreException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_ArrayStoreException.class));
            case "java.lang.ClassCastException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_ClassCastException.class));
            case "java.util.ConcurrentModificationException": return putMarshaller(a0, GWT.create(Marshaller_for_java_util_ConcurrentModificationException.class));
            case "java.lang.IndexOutOfBoundsException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_IndexOutOfBoundsException.class));
            case "java.lang.NegativeArraySizeException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_NegativeArraySizeException.class));
            case "java.lang.NullPointerException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_NullPointerException.class));
            case "java.lang.StringIndexOutOfBoundsException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_StringIndexOutOfBoundsException.class));
            case "java.lang.UnsupportedOperationException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_UnsupportedOperationException.class));
            case "java.lang.AssertionError": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_AssertionError.class));
            case "java.lang.RuntimeException": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_RuntimeException.class));
            case "java.lang.StackTraceElement": return putMarshaller(a0, GWT.create(Marshaller_for_java_lang_StackTraceElement.class));
            case "org.jboss.errai.demo.busstress.client.shared.RecursiveObject": return putMarshaller(a0, GWT.create(Marshaller_for_org_jboss_errai_demo_busstress_client_shared_RecursiveObject.class));
            case "org.jboss.errai.common.client.PageRequest": return putMarshaller(a0, GWT.create(Marshaller_for_org_jboss_errai_common_client_PageRequest.class));
            default: return false;
          }
        }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mbarkley Max Barkley
                Reporter:
                slavap Slava Pankov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 2 days
                  2d
                  Remaining:
                  Remaining Estimate - 2 days
                  2d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified