Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-106

Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.1.0
    • 0.1.0
    • impl
    • None
    • Patch Available

    Description

      While investigating PIG-99, in TestBuiltin.java line 315:

      for (int i = 0; i < LOOP_COUNT; i++) {
          for (int j = 0; j < LOOP_COUNT; j++) {
              sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
          }
      }
      

      doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.

      Could be replace with:

      for (int i = 0; i < LOOP_COUNT; i++) {
          for (int j = 0; j < LOOP_COUNT; j++) {
              sb.append(i);
              sb.append("\t");
              sb.append(i);
              sb.append("\t");
              sb.append(j % 2);
              sb.append("\n");
          }
      }
      

      Attachments

        1. PIG-106-v01.patch
          0.7 kB
          Benjamin Francisoud
        2. PIG-106-v02.patch
          57 kB
          Benjamin Francisoud
        3. PIG-106-v03.patch
          56 kB
          Benjamin Francisoud

        Issue Links

          Activity

            People

              francisoud Benjamin Francisoud
              francisoud Benjamin Francisoud
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: