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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.1.0
    • Fix Version/s: 0.1.0
    • Component/s: impl
    • Labels:
      None
    • Patch Info:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: