Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5577

Builder.mapResult does not forward sizeHint

    Details

    • Type: Improvement
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.10.0-M2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Builder.mapResult returns an anonymous proxy that forwards most method calls to the target builder and overrides result to apply a function to the target Builder's result. Unfortunately this proxy does not forward sizeHint and related methods. This causes excessive copying and oversized buffer allocations when mapped Builders are used (ArraySeq uses a mapped Builder so this situation is not uncommon).

      The fix is easy: add
      def sizeHint(size: Int) = self.sizeHint(size)
      to the mapResult proxy.

        Attachments

          Activity

            People

            • Assignee:
              prokopec Aleksandar Prokopec
              Reporter:
              c9r Chris Sachs
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: