Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.7.4, 1.8-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      The DGM/PDGM methods

      • StringBuffer leftShift(String, Object)
      • StringBuffer leftShift(StringBuffer, Object)
      • StringBuilder leftShift(StringBuilder, Object)

      are (up to at minimum ten times) slower than they should be. Possible faster implementations are

          public static StringBuffer leftShift(String self, Object value) {
          	final CharSequence chseq;
          	if (value instanceof CharSequence)
          		chseq = (CharSequence)value;
          	else
          		chseq = String.valueOf(value);
          	final int capacity = 2 * (self.length() + chseq.length());
              return new StringBuffer(capacity).append(self).append(chseq);
          }
      
          public static StringBuffer leftShift(StringBuffer self, Object value) {
          	if (value instanceof CharSequence)
          		return self.append((CharSequence)value);
          	else
          		return self.append(value);
          }
      
          public static StringBuilder leftShift(StringBuilder self, Object value) {
          	if (value instanceof CharSequence)
          		return self.append((CharSequence)value);
          	else
          		return self.append(value);
          }
      

        Attachments

        1. AppendPerformance.java
          1 kB
          Alexander Veit
        2. improvedLeftShift.java
          0.8 kB
          Alexander Veit

          Activity

            People

            • Assignee:
              Guillaume Guillaume Delcroix
              Reporter:
              veita Alexander Veit
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: