Uploaded image for project: 'Swift'
  1. Swift
  2. SR-15061

EnumeratedSequence underestimatedCount does not forward the base enumeratedCount

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Standard Library
    • Labels:
      None

      Description

      All lazy adaptors forward the underestimatedCount property of Sequences excepted EnumeratedSequence:

      let array = [1, 2, 3, 4, 5]
      let enumerated = array.enumerated()
      print(enumerated.underestimatedCount)  // 0
      

      Is this expected behavior? Does it create unnecessary reallocations in such code:

      // array: some array 
      let result = Array(array.enumerated().map { $0 })  // this Sequence underestimatedCount is 0
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            laclouis5 Louis Lac
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: