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

String.substring() copies unnecessarily

XMLWordPrintable

    • 1.0.2
    • sparc
    • solaris_2.5
    • Not verified

      I was surprised to find that String.substring makes unnecessary copies,
      even though the underlying character array is never modified,
      and the string itself is designed to be immutable.

      Also, with all the extra copying going on, the field String.offset
      is now identically zero. This is probably also a performance bug,
      even if the copying were somehow desirable.

      Background: I was assuming that I could read a file into a big char[]
      and then parse around in it, making constant-size String objects as I
      went. I was surprised to find that String objects are non-constant in
      size, even when created from an explicit body array.

            flar Jim Graham
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: