Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4982981

Methods that work with StringBuffer have no StringBuilder equivalent

XMLWordPrintable

    • b48
    • sparc
    • solaris_2.5, solaris_8

      Reported by Remi Forax <###@###.###>

      Severals methods that works with StringBuffer have no
      StringBuilder equivalent.

      1) There is no contentEquals(StringBuilder) in class String.

      2) In StringBuilder and StringBuffer, there is a
          method append(StringBuffer sb) but no
          append(StringBuilder).

      In case 2, the the code :
         StringBuilder b=new StringBuilder.append(new StringBuilder());

      I think the method append(CharSequence) must be called instead.
      It works but i think that a method append(StringBuilder) could
      perform better using getChar(...) instead of
      a loop over each character.

      The append(StringBuilder) could be inserted to
      AbstractStringBuilder.

      Moreover, the class par of the String documentation have
      lot of links to StringBuffer. I think, all this links
      could be transfered to StringBuilder.

      PS: lot of methods in AbstractStringBuilder return an
         AbstractStringBuilder that is not used in overriden
         counterparts in StringBuffer and StringBuilder.
         Perhaps, this methods could return void to avoid
         a supplementary pop opcode (poor man optimisation :)

            mmcclosksunw Michael Mccloskey (Inactive)
            jdriscol Jerry Driscoll (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: