Scala Programming Language
  1. Scala Programming Language
  2. SI-5577

Builder.mapResult does not forward sizeHint

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.10.0-M2
    • Fix Version/s: None
    • Component/s: Collections
    • 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.

        Activity

        Hide
        Adriaan Moors added a comment -

        alex, please re-assign if needed

        Show
        Adriaan Moors added a comment - alex, please re-assign if needed

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development